Pelle
Pelle

Reputation: 1252

Can grafana plot a influxdb time series of type string?

I have a dataset in influxdb from my thermostat with its mode in string format ("off", "hot water" or "central heating")

I want to plot two lines in grafana, one for "hot water" and one for "central heating" next to the current temperature. The possible values for the sets are just "1" and "0".

It seems this is (currently) impossible to do in influxdb (https://github.com/influxdata/influxdb/issues/8627), so I hope it is possible to make this transformation in grafana.

Is there a way to make this transformation in grafana?

Dataset:

name: boiler indicator
time                value
----                -----
1539706320366630912 off
1539706380315879936 off
1539706440368925184 off
1539706500364559872 off
1539706560358993152 off
1539706620359011840 off
1539706680363074048 off
1539706740348193024 hot water
1539706800366929920 off
1539706860366509056 off

desired result for hot water:

name: hot water
time                value
----                -----
1539706320366630912 0
1539706380315879936 0
1539706440368925184 0
1539706500364559872 0
1539706560358993152 0
1539706620359011840 0
1539706680363074048 0
1539706740348193024 1
1539706800366929920 0
1539706860366509056 0

Upvotes: 1

Views: 2387

Answers (1)

Jan Garaj
Jan Garaj

Reputation: 28656

No, Grafana just shows data provided by your TSDB. Hackish workaround for your InfluxDB structure; try:

SELECT count(*) 
FROM "hot water"
WHERE "value"='hot water' AND time>NOW()-10m 
GROUP BY time(1m) fill(0)

It is ineffective because filtering by field needs table full scan. It can be slow for large dataset.

You should change your InfluxDB structure if you want to have an effective query and easier Grafana visualization -> use numeric field values + eventually use string tag.

Upvotes: 1

Related Questions