I want to rename filtered data series that I have prepared for a Grafana dashboard panel based on tag values. Basically, I store temperatures and other sensor data from indexed locations. To identify each sensor, I define store the type and value as field (_field: temperature, _value: [numeric]), and identify all sensors with identical type with a tag set of indices (e.g. 1-1-1). The indices have a limited range: 1-50 at most.
An example row in the database looks like: [measurement,time,value, field: Temperature, tag: idA, idB, idC]. In Grafana I query data with InfluxQL, starting with from(bucket), range, filter(measurement), and then I:
- filter by measurement, field and idA = [1, 3, 5],
- pivot column=fieldname, row=time, value=value
- drop columns, keep only time, “Temperature” (fieldname)
The query returns one table per sensor with the identical column “temperature” - all the tables are displayed as a single series in the Grafana dashboard graph panel (one color). I want to display each sensor data series in a different color, thus, I rename the column into "Temperature {idA} {idB} {idC}. I tried to
- use rename() → no access to record with tag values
- use map(fn: (r) => … with “Temperature”: "Temperature ${r.tagA} ${r.tagB} ${r.tagC}) → works but feels inefficient, overwrites data in each data point
Is map() the right choice? I would prefer to rename the column name of the pivoted table once, instead of the_field value in every data point.