vbessler / grafana-pictureit

Grafana Panel Plugin. Allows Measurement Values to be Overlaid on top of a Picture
Other
18 stars 20 forks source link

Influx 2.0 beta support #30

Open wz2b opened 4 years ago

wz2b commented 4 years ago

Is there any reason this plugin wouldn't work with influxdb 2.0 ? I attempted this:

from(bucket: "powermon")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "modbus")
  |> filter(fn: (r) => r._field == "pv1")
  |> last()
  |> yield(name: "value")

That gets the last value of field 'pv1' and returns it with the name 'value' which is what I think PictureIt wants to see. The metric name is A while the configuration calls it "A-Series" but I think that's the same thing.

The result of this query is

,result,table,_start,_stop,_time,_value,_field,_measurement,address,gateway,register
,value,0,2020-01-29T21:38:20.148301123Z,2020-01-29T22:38:20.148301123Z,2020-01-29T22:38:14.259Z,0,pv1,modbus,28,10.7.4.131,1252

Should this work? I have a feeling the result of the query is something that the plugin just doesn't understand.

wz2b commented 4 years ago

The problem is right here:

if(sensors[sensor].name == valueMaps[valueMap].name) {

The result that comes back from that query has a 'name' field that's the concatenation of a bunch of the tags. This plugin thinks the names don't match, so it never updates the value. I proved this by just eliminating that test

if(true || sensors[sensor].name == valueMaps[valueMap].name) {

and it works. Obviously, though, that's not really a solution. The right thing to do is somehow figure out how to manipulate the data source so that things come back with a name the plugin understands. I don't know how to do that.

wz2b commented 4 years ago

Maybe this helps as well. This is what comes in as datList into onDataReceived. Note that the 'target' and 'alias' are both crazy ... it made those strings out of all the tags on that measurement.

[
  {
    "alias": "modbus pv1 address=28 gateway=10.7.4.131 register=1252",
    "target": "modbus pv1 address=28 gateway=10.7.4.131 register=1252",
    "datapoints": [
      [
        0.74,
        1580327424260
      ]
    ]
  }
]