groupBy不会在连接后使用eval创建的标记进行分组

时间:2018-01-18 17:30:15

标签: influxdb kapacitor

  • 您的操作系统(或分发)的完整详细信息,例如64位Ubuntu 14.04。
    • 在MacOSX上运行InfluxDB / Kapacitor / Chronograf作为Docker容器,最新的Docker。
  • 您正在运行的Kapacitor版本
    • 最新,1.4。
  • 您是使用预先构建的软件包安装它,还是从源代码构建它。
    • 官方Docker容器

我们遇到了TICKscript及其groupBy行为的问题。

我们有两组测量,indoor_temperatures和outdoor_temperatures,我们用批量查询。

查询如下:

var out_temp = batch
    |query('SELECT mean(temperature) FROM yyyy')
        .every(10s)
        .period(120d)
        .groupBy(time(1h))
        .fill(0)

var in_temp = batch
    |query('SELECT mean(temperature) FROM xxxx')
        .every(10s)
        .period(120d)
        .groupBy(time(1h))
        .fill(0)

如果我们将两者都HTTP,他们会创建以下数据集:

{
  "series": [
    {
      "name": "outdoor_temperatures",
      "columns": [
        "time",
        "mean"
      ],
      "values": [
        [
          "2017-09-20T17:00:00Z",
          0
        ],
        [
          "2017-09-20T18:00:00Z",
          11.5
        ]
        ... the rest
      ]
    }
  ]
}

{
  "series": [
    {
      "name": "indoor_measurements",
      "columns": [
        "time",
        "mean"
      ],
      "values": [
        [
          "2017-09-20T17:00:00Z",
          585.44012944984
        ],
        [
          "2017-09-20T18:00:00Z",
          592.94890510949
        ]
        ... the rest
      ]
    }
  ]
}

现在我们完全加入它们,这给了我们预期的结果

out_temp
    |join(in_temp)
        .as('out_temp_mean', 'in_temp_mean')
        .tolerance(5m)
        .fill(0)

httpOut:

{
  "series": [
    {
      "name": "outdoor_temperatures",
      "columns": [
        "time",
        "in_temp_mean.mean",
        "out_temp_mean.mean"
      ],
      "values": [
        [
          "2017-09-20T17:00:00Z",
          586.10175438596,
          0
        ],
        [
          "2017-09-20T18:00:00Z",
          592.94890510949,
          11.5
        ]
        ... the rest
      ]
    }
  ]
}

哪个看起来很完美。当我们想要围绕out_temp_mean.mean向下并将其分组

时,问题就会出现

所以我们继续并扩展脚本

out_temp
    |join(in_temp)
        .as('out_temp_mean', 'in_temp_mean')
        .tolerance(5m)
        .fill(0)
    |eval(lambda: string(floor("out_temp_mean.mean")))
        .as('bucket')
        .tags('bucket')
        .keep('out_temp_mean.mean', 'in_temp_mean.mean')

之后输出STILL看起来应该是:

{
  "series": [
    {
      "name": "outdoor_temperatures",
      "columns": [
        "time",
        "in_temp_mean.mean",
        "out_temp_mean.mean",
        "bucket"
      ],
      "values": [
        [
          "2017-09-20T17:00:00Z",
          586.99190283401,
          0,
          "0"
        ],
        [
          "2017-09-20T18:00:00Z",
          592.94890510949,
          11.5,
          "11"
        ]
      ]
    }
  ]
}

现在剩下的就是按新标记桶分组值:

out_temp
    |join(in_temp)
        .as('out_temp_mean', 'in_temp_mean')
        .tolerance(5m)
        .fill(0)
    |eval(lambda: string(floor("out_temp_mean.mean")))
        .as('bucket')
        .tags('bucket')
        .keep('out_temp_mean.mean', 'in_temp_mean.mean')
    |groupBy('bucket')

之后一切都出了问题,我们迎接series: null

{
  "series": null
}

这是预期的行为吗?一个bug?或其他什么?

如果有人想知道,也会将其归档为https://github.com/influxdata/kapacitor/issues/1765

0 个答案:

没有答案