Is there any way that one can use data, in my case from InfluxDB, where one of the values I would like to alert on is a string match? I am using the HAProxy Telegraf plugin and as far as I can tell, the only way to get the up/down status is from a status field that is a string. Is there any method to query the data and convert it to a simple 0 or 1 or any way to natively alert based on the string value?
I don’t see anything that will return an integer that shows if an individual object that is type=server is up or not. I can only see the number of active servers are in a backend but then the backend also doesn’t have a total count of servers either so I can’t determine it from that either.
In my example I am checking if port 8282 is open. If port is open I get result_type=success and if not then result_type=connection_failed. Then I used InfluxDB function map to iterate over each row and inside map I called strings.replaceAll function to replace connection_failed with 0 and success with 1 (those are still strings). After that I needed to convert string to float (or integer value) with toFloat(). After that I used Reduce expression in order to get one alert check per time series and finally set threshold expression to alert
Thanks for that! I have something that’s functional based on your Flux query and I’ll have to spend a bit of time optimizing the data as the HAProxy input can provide a wide range of values for my status field and it doesn’t like it when there is an undefined string that isn’t mapped when converting to float. It’s my first time digging into Flux as I’ve been using InfluxQL due to the lack of wizard type interface so this is certainly an experiment for me.
Just to give a potentially helpful query example, in this case I am using a map() function and if/else statement to create a new column (AtOperatingTemp, which contains either true or false) based on the value of the field.