Extracting individual units out of query InfluxDB

  • What Grafana version and what operating system are you using?

Grafana v9.1.3.1 on Chrome, Windows 10

  • What are you trying to achieve?

I have an InfluxDB database of time series data. It is organized with multiple measurements, with the measurement name serving as the field label, metadata stored as a single tag example: {unit=“degC”} or {unit=“kW”} or {field_tag=“CT-030”} and then several {time:value} entries containing the time series data. Each database (of ~20) has about 15-30 measurements with varying units and they are then joined by time. I am attempting to assign units to each field instead of doing it manually.

  • How are you trying to achieve it?

I have two queries active, one is the standard query for data from all measurements in that database “SELECT last(“value”) FROM /./ WHERE time >= now() - 1h and time <= now() GROUP BY time(1s)”

The new query that returns me units is "SHOW tag values FROM /./ WITH key = “unit”. This query, looking at the raw data, does successfully return me the value as a string for each measurement in the database with the same field name as the time series data. However here I hit a brick wall. I am trying to use the transformation “Config Data from Query” but I have to do it before joining by time apparently. I am able to assign a unit, but only from one measurement (the first result) at a time, to either a specific “field by name” or “field by type” for all time series, and then join it after. Right now it seems like I would have to do this transform one by one instead of being able to assign the unit to that field based on the field name… Am I missing something simple or could this be a feature request?

In the selector for “config data from query” I am able to select several lines of the units query that returned several fields - all identical (“B”,“B”,“B”…), however, only the first returned measurement appears no matter which “B” I choose. Only by changing the query to specifically call out the exact measurement I want can I pick which field is used as the unit reference (and then from there I could repeat this dozens of times and sync it up but at that point I’d just as well do the manual overrides)

  • What happened?

Time series with one unit applied to all data fields

  • What did you expect to happen?

Units applied to fields joined by field name prior to joining by time

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

No but the Grafana UI for “config data by query” seems maybe a bit bad with updating fields (old info sticks around)

  • Did you follow any online instructions? If so, what is the URL?