Transform Influx Result to true/false


my influx data source has one measurement which I want/need to transform. It is the status of a heating device in which e.g. 19 means “everything is fine and heating is turned off” while “3” means “in operation and producing heat” etc.

Basically what I want is to transform this. Easiest dirty way: Whenever the result of the query is NOT 19, set it to true/1 otherwise to false/0. Nicer: When the value is a or b or c, set it to 0,5. If it is d set it to 1. If it is e set it to 0.

I am not familiar with Influx Flux, just rudimentary influxql. Not sure if this is better solved in the Influx query or a Grafana transformation (which I fail to understand). I fiddled around with value transformation but that only changes the display name and not the value (or I am just too blind).

Any suggestions?

Welcome @jkoopmann

Have you considered using Value Mappings in Grafana? Something like this:

When value = 3

When value = 19

Is the output always 3 or 19?

I monitor the error codes on a motor VFD and there are about 30 codes. I just put each of them into Grafana as a value mapping and then the “plain English” text is displayed instead of the two-digit code.

I have in fact. The point is that I need this as a time series (forgot to mention that, sorry). So I want to see when the heating was turned on and when not. So I want to map several potential status codes to “heating turned on” and others to “heating turned off”. Since Time Series will not likely perform well with values “heating turned on” and “heating turned off” I am happy to settle with “1” (on) and “0” (off).

No it is not only 13,9 but a number of codes. I am aware that a simple status display showing what happens this very moment is easy to achieve via Value Mapping.

This grafana plugin might be of help woth time series and icons for on off

1 Like

If you wish to use Flux to do the above, these examples should help: