Hello,
I am using Grafana v9.1.2 in a docker image, migrated from an older version I am trying to create an alert from an InfluxDB Query that returns a boolean value.
In the panel, it looks fine
Unfortunately I am not the only user. Many are “less proficient” when it comes to these queries. We also have to deal with a lot of alerts that are configured for InfluxQL (as well as lots of dashboards). The most workable way I have found so far is to duplicate the data source and change the query language there. Then use that data source for new alerts. But I haven’t looked into this too much and haven’t got it to work yet.
Is the problem with Alerts on booleans an issue which is still unresolved? Now Flux is no longer an option I would like to see if there is an option to use the boolean for alerts.
I am currently looking for a solution for this. I want to alert based on a boolean field from an influx 1.8 measurement. It seems like it should be simple: if true then alert. Is there a reasonable way to do this?
Welcome @nathanpegram to the Grafana forum. I guess the creators of InfluxQL did not think that far ahead! I am not really good with InfluxQL, but maybe if you’re looking to alert on the presence of true values within a time window (e.g., “is this boolean field true at least once in the last 5 minutes?”), you can use COUNT() with a WHERE clause.
SELECT COUNT("your_boolean_field") AS boolean_as_int
FROM "your_measurement"
WHERE "your_boolean_field" = true
AND time >= now() - 5m
GROUP BY time(1m)
FILL(0)
@grant2, that sounded like a good idea. But having just tried it, I find that no data is returned when the where condition "your_boolean_field" = true is not met. I was expecting 0 counts to be returned. If I change the condition to look for false, I get counts as expected. It’s possible I could choose to ignore when this alarm is in error as it would probably come out of error if there actually were a true value, but that isn’t ideal.