grafana / influxdb-flux-datasource

Grafana datasource plugin for Flux (InfluxDB)
Apache License 2.0
51 stars 21 forks source link

Does not work together with the official piechart plugin #77

Open theodiefenthal opened 4 years ago

theodiefenthal commented 4 years ago

I have a report which creates 10 rows, all with the same timestamp but different tags.

I run the following query, to get the data from the last report run:

lastTimestamp = from(bucket: "reports")
  |> range(start: -3d)
  |> filter(fn: (r) => r._measurement == "report1" and r._field == "numPerCategory")
  |> group()
  |> last()
  |> tableFind(fn: (key) => true)
  |> getRecord(idx:0)

from(bucket: "reports")
  |> range(start: -3d)
  |> filter(fn: (r) => r._measurement == "report1" 
                       and r._field == "numPerCategory"
                       and r._time == lastTimestamp._time)
  |> group()
  |> yield()

If I run that query in Chronograf, it returns the desired data as a table. In Grafana, the query also works in principle: If I choose a Graph visualization, it shows the data. Of course, it doesn't draw lines, but just 10 points at the same timestamp as expected.

If I choose Pie-Chart and for the query "Format as time series", I get a pie with just one value (The one of the last queried row), not what I expected: A pie with ten values. If I choose "Format as table", the plugin crashes with "TypeError: this.datapoints is undefined".

If I change the very last |> group() to |> group(columns: ["category"]) nothing changes, same result with Format as Table or format as time series.

For reproduction: I'm on Grafana 6.7.1, using the grafana/grafana docker image and use the flux plugin via GF_INSTALL_PLUGINS on a start from scratch today.

theodiefenthal commented 4 years ago

This issue seems to still exist with latest Grafana 7.1.3 and Influx 1.8.1 and now built-in flux support. I wasn't able to get a visualization to work, even with any kind of Transformations applied to the data.