How to configure alert for string (non numeric) metric value

Greetings,

I have a TIG environment (Grafana 10.4.1, InfluxDB 1.8.10, Telegraf 1.26) and I cannot seem to figure out how to setup an alert for a condition that is a non-numeric string.

Under Alert Rules I have a rule where the query successfully results in “ONLINE”. All of the possible expressions are numeric based. Thresholds, ranges, is above, is below, etc.

How do I set up an alert rule where an alert triggers if the result of the query is any string other than “ONLINE”? Or, for different strings do different things; “UNAVAILABLE”, “OFFLINE”, “FAULTED”, “DEGRADED”?

I have plowed through all of the options and conditions under “2. Define query and alert condition” block and I cannot seem to find something that will properly handle the query result and process it as an alert condition.

Thank you.

I managed to get it working…

Output of query A “ONLINE” into B:Reduce/Last/Strict into C:Threshold B above 0

In case anyone finds this post and is on a similar path

Generally, you need to create numeric value, e. g. you are counting occurrence of some string.

Example (not real influx, sql query):

SELECT
  time, 
  COUNT(*) 
FROM db
WHERE
  timecondition
  AND status='ONLINE' 

My current influxql query is:

SELECT
“size”
FROM “zpool_stats”
WHERE (“host” = ‘testhost.internal’ AND “name” = ‘testpool’)
AND $timeFilter GROUP BY “state”, “state”

this results in:
Table
ONLINE 1712688960000

Then B: Reduce Input A Last() Strict
Then C: Input B is above 0

I can’t tell if that works or not.