Closed wz2b closed 4 years ago
Dear Christopher,
regarding proper field name aliasing, https://github.com/grafana/influxdb-flux-datasource/issues/42#issuecomment-532402207 by @mdb5108 might help you along.
With kind regards, Andreas.
That actually did help, a little, in terms of being a workaround. Well, sort of. I changed my querion to this
from(bucket: "powermon")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "modbus")
|> filter(fn: (r) => r._field == "pv1" or r._field == "pv2" or r._field == "pv3" or r._field == "pv4" or r._field == "pv5" or r._field == "pv6" or r._field == "pv7")
|> last()
|> map(fn: (r) => ({_value:r._value, _time:r._time, _field:r._field}))
that sets _field to the simple, actual field name. When it makes it to grafana, though, it has an extra space in it:
1: Object { alias: " pv2", target: " pv2", datapoints: (1) […], target: " pv2", … }
```
so using this query all I had to do to the plugin was add a .trim() but I'm still suggesting something is not quite right between what comes out of this driver and what makes its way in through the plugin API ... hmmmm.
That sets _field to the simple, actual field name. When it makes it through Grafana, though, it has an extra space in it.
Huh? Do you observe this as well, @wetterfrosch?
That sets _field to the simple, actual field name. When it makes it through Grafana, though, it has an extra space in it.
Huh? Do you observe this as well, @wetterfrosch?
Yes, but haven't investigated it in much detail. I darkly recall that the rendered legend-title might be a composition of _measurement and _field, so @wz2b tinker with
|> map(fn: (r) => ({_value:r._value, _time:r._time, _field:r._field, _measurement: "foo"}))
jep, if you just use _measurement and leave _field empty you'll get the space at the end.
Yeah. That's right. If I set measurement to 'foo' then instead of " pv2" I get "foo pv2" ... so something somewhere in there needs to stop doing that, at least to say if _measurement == "" (or null or nil or strlen=0 or whatever) then don't put the space in there when you join the strings. So I think that's a bug ... but I'm not clear on if it's a problem with this datasource, or further upstream in grafana.
In 7x, the tags/labels are now included in the field display name. please open a new issue for suggestions on how to do this better, but I hope a big improvement
When I request values back from influx from a plugin (e.g. PictureIt) I get a weird result. Here is the query:
The text result is this:
I intercepted the 'data-received' callback to see what I was getting (registering with base class MetrisPanelCtrl) and I see this:
In this particular case, what's coming back is actually a table of 7 values. Each one has a correct _field and _value and the _field name is pv1, pv2, pv3, ... in other words, it makes sense. What doesn't make sense to me is that I get this 'alias' that's everything.
Is this a bug in the driver, or minimally a difference between influx 1.7 and 2.0? Should the resultant 'target' be mapped to the _field (the actual name of the field) ?