2
votes

Our company stores pool controller data in influxdb and uses Grafana to plot dashboards with the infux data. For reasons beyond my influence some of the data is stored as a string, for example:

time                filtration_mode filtration_status filtration_time_remaining
----                --------------- ----------------- -------------------------
1520676696532993722 MAN             OFF               0 

The company now wants to use the string values in a time/graph element that only displays integer/floats/etc. Is there a way to query the influxdb so that the query returns predefined integer when a string value is encountered. For example return a 0 when filtration_status = OFF and a 1 when filtration_status = ON in the example above.

I know the company can change the way the data is inserted in influx and insert a 0/1 but unfortunately the insert proces is out of scope for me so i have to do with what i can query from the influxdb.

Thanks

1

1 Answers

0
votes

You can use flux (InfluxData’s new functional data scripting language designed for querying, analyzing, and acting on data) to query the data and a map function to transform it.

See flux documentation: https://docs.influxdata.com/flux/v0.12/introduction/getting-started/

Map function: https://docs.influxdata.com/flux/v0.12/functions/transformations/map/

Custom functions with flux: https://docs.influxdata.com/flux/v0.12/functions/custom-functions/