Skip to content

groupBy not grouping by a tag created with eval #1765

@petetnt

Description

@petetnt
  • Full details of your operating system (or distribution) e.g. 64-bit Ubuntu 14.04.
    • Running InfluxDB/Kapacitor/Chronograf as Docker containers on MacOSX, latest Docker.
  • The version of Kapacitor you are running
    • Latest, 1.4.
  • Whether you installed it using a pre-built package, or built it from source.
    • Official Docker container

We are running into an issue with TICKscript and its groupBy behaviour.

We have two sets of measurements, indoor_temperatures and outdoor_temperatures, which we query with a batch.

The queries look as follows:

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)

If we HTTP out both of them, they create the following sets of data:

{
  "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
      ]
    }
  ]
}

Now we do a full join of them, which gives us expected results

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
      ]
    }
  ]
}

Which looks perfect. The issue raises when we want to round the out_temp_mean.mean down and groupBy it

So we go ahead and extend the script

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')

After which the output STILL looks as it should:

{
  "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"
        ]
      ]
    }
  ]
}

Now only thing left is to group the values by the new tag bucket:

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')

After which everything goes awry and we are greeted with series: null

{
  "series": null
}

Is this expected behaviour? A bug? Or something else?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions