teeeeee
teeeeee

Reputation: 747

How to indicate that a there has been no data from query for x amount of time in Grafana?

I have time series data of temperatures from x10 different sensors, stored in an InfluxDB (v1.8) database, and am displaying the “current” value using a Bar Gauge.

The sensors should get a new value roughly every hour, but I would like some way to show if the sensor has failed (e.g. hasn’t had any data for let’s say 1 day). The problem is that data is always being displayed, no matter how old it is (as expected, because I am selecting LAST):

enter image description here

I have tried to use a WHERE time>now() - “some time” clause in InfluxDB, but now the relevant values have been removed entirely:

enter image description here

What would be a good way to fix this? (ideally whilst still taking advantage of the GROUP_BY feature that I’m using, which is nice)

Upvotes: 1

Views: 605

Answers (1)

user1874594
user1874594

Reputation: 2493

try the fill in your time grouping, which allows you to specify how to handle missing data in your query results. e.g. fill(previous) to report the value from the previous time interval for time intervals with no data or use fill(null) to fill the missing values with null or None, and then use InfluxDB's built-in fill function to perform any additional queries and actions on the data².

SELECT LAST(temperature) FROM sensors
WHERE time > now() - 7d
GROUP BY time(1h), sensor_id
FILL(previous)

This query will return the last temperature value for each sensor in each hour for the past 7 days, & fill any gaps with the previous value. other options such as linear, none, or a specific value to fill the missing data


References:

  1. InfluxDB: How to deal with missing data? - Stack Overflow.

  2. Timeseries (InfluxDB): How to deal with missing data? - Data Science Stack Exchange.

  3. InfluxDB: query aggregations but deal with missing data - Stack Overflow.

  4. influxdb - How to query from an Influx database with an absent field - Stack Overflow.

  5. InfluxDB Documentation: Query Data Fill.

  6. InfluxDB Documentation: Query Language Data Exploration.


Upvotes: 0

Related Questions