grafana / influxdb-flux-datasource

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

Stacked bars are not displayed correctly #11

Closed nikolay-t closed 4 years ago

nikolay-t commented 6 years ago

We see that stacked bars are not displayed correctly with data coming from Flux datasource. We tested with Grafana 5.2.1 and the latest 5.3.2 - the pictures are the same.

Issue N1:

  1. Bars should start from zero, but they are "hanging" above
  2. Number of bars is not correct compared to actual data (i.e. green bars around 14:00 and below yellow lines are "ghosts" and should not be displayed). image Note: selecting one bar makes graph displaying correctly.

Source CSV data:

#datatype,string,long,string,dateTime:RFC3339,long
#group,false,false,true,false,false
#default,_result,,,,
,result,table,process_name,_time,_value
,,0,dtquery,2018-10-28T06:00:00Z,2
,,0,dtquery,2018-10-28T07:45:00Z,2
,,0,dtquery,2018-10-28T15:45:00Z,1
,,0,dtquery,2018-10-28T16:00:00Z,1
,,1,objcontrolsvc,2018-10-28T08:00:00Z,1
,,1,objcontrolsvc,2018-10-28T08:15:00Z,1
,,2,storageserver,2018-10-28T08:00:00Z,2
,,2,storageserver,2018-10-28T09:15:00Z,2
,,2,storageserver,2018-10-28T13:45:00Z,2
,,2,storageserver,2018-10-28T14:15:00Z,2
,,2,storageserver,2018-10-28T16:45:00Z,2
,,2,storageserver,2018-10-28T18:45:00Z,3
,,2,storageserver,2018-10-28T19:00:00Z,1
,,2,storageserver,2018-10-28T20:00:00Z,2
,,2,storageserver,2018-10-28T20:15:00Z,2
,,2,storageserver,2018-10-28T20:30:00Z,2
,,2,storageserver,2018-10-28T20:45:00Z,1
,,2,storageserver,2018-10-28T21:45:00Z,1
,,2,storageserver,2018-10-28T22:00:00Z,1
,,2,storageserver,2018-10-28T22:30:00Z,2
,,2,storageserver,2018-10-28T23:30:00Z,2
,,2,storageserver,2018-10-29T00:45:00Z,2

Issue N2: Bars are getting displayed as wide rectangles image

Source CSV data:

#datatype,string,long,string,dateTime:RFC3339,long
#group,false,false,true,false,false
#default,_result,,,,
,result,table,process_name,_time,_value
,,0,storageserver,2018-10-29T00:45:00Z,2
davkal commented 5 years ago

The floating stacks one is a general Grafana issue and is caused by not all series having a value for the union of all time values, see: https://github.com/grafana/grafana/issues/9294

The wide-bar issue is a bit of an outlier, so I created an issue to discuss where this needs to be fixed: https://github.com/grafana/grafana/issues/14130

nikolay-t commented 5 years ago

@davkal Thanks. However we don't see same issues with other datasources, i.e. SQL InfluxDB or Prometheus. Can it be that Flux datasource provides data in a way that triggers those Grafana issues?

davkal commented 5 years ago

I believe so, namely, when asked for data in a time range the new flux datasource returns only the datapoints that are there, whereas classic Influx and Prometheus have returned null values for every interval (step) in the requested range. You can observe this by using the Query Inspector in the other datasources, they will return data that looks like [ts1, null], [ts2, null], [ts3, 4], [ts4, null], .... Classic Influx even has a query keyword to make that explicit: fill(null).

nikolay-t commented 5 years ago

Agree, see this too if I create InfluxDB SQL query without aggregation and group by time. However it does not seem like we will have fill(null) in Flux language any time soon. As the result, now it makes stacked bars not usable with Flux source. What if we change Flux plugin a way that it will add null values after certain time (will equal to width of bar). Or you feel like 9294 will be resolved soon?

davkal commented 5 years ago

grafana/grafana#9294 needs to be fixed in the vendored flot code, since it should work for all datasources that return interleaved data points. It's not on the immediate roadmap, but I encourage you take a stab at it.

The wide bars should be an easy fix too (max-limiting the calculated bar width in graph.ts) if you want to give it a go.

bryanspears commented 5 years ago

Any chance there a query Alias could be exposed? I did a join on two measurements and the resulting legend "name" for the result set is crazy long.

bryanspears commented 5 years ago

For anyone's future reference: doing a join causes the _field value to get all mucked up. Quick and dirty way to have your legend show a pretty value: |> set(key: "_field", value: "Label Here")

ryantxu commented 4 years ago

I'll close this unless there is something clear we could/should do in the datasource plugin to better support this