I’ve read this topics, which is giving a lot of good advice, but using the Flux language.
Is there a way to create alerts with influxQL? I’m a neewbie and, although I can create alerts with simple queries, I can’t get it to iterate with different variable values.
For example, I’d like to create an alert that’s triggered if one of my routers reboots, testing whether the uptime is less than 20 seconds. I can do this with this request:
SELECT sysUpTime as UpTime FROM snmp WHERE agent_host =~ /^10.211.0.2$/ AND time > now() - 1m
If you used the query above without the regex and in an alert, like this (my syntax is probably wrong)…
SELECT sysUpTime as UpTime FROM snmp WHERE agent_host = '10.211.0.2' AND time > now() - 1m
…then do you get any errors? In other words, is the query in the alerting section giving errors when it contains the regex, but otherwise works fine without the regex?
If you use the regular expression =~, the query expects a parameter of type /^something$/ to exactly match the value ‘something’. The same applies to =, but without ‘match exactly’: only if the value is the same as ‘something’. I was using this syntax to iterate through my variable, but if you prefer, we can use the simpler syntax for testing.
So no, I don’t have any errors with the query (and your syntax is good!):
SELECT sysUpTime as UpTime FROM snmp WHERE agent_host = '10.211.0.2' AND time > now() - 1m
By the way, I’ve tried to setup an alert on a different panel which worked well (without iterating trough any variables). My problem seams to be that we can not setup alerts on non graph or timeseries panels: The alert tab and alert annotations are only supported on graph and timeseries panels.
Hi @codi639 and thanks for the further explanation.
In your query A of the Alerting section, you are using this query…
SELECT sysUpTime as UpTime FROM snmp....
and not this one, right?
SELECT last(sysUpTime) FROM snmp....
Going back to your desire to get the multidimensional alerting working, the end result is to get something like this where you can see which agent_host(s) have sysUpTime below 20, right? In other words, a view like this (but with the agent_host instead of cpu), right?