I have a prometheus query that returns positive values tracking how many days left until X expires and -1 if it has already expired.
I have an alert rule that uses this query and a ‘Reduce’ expression with “Last” function. (the expression is called “last”.
I want to compare the value of $last and produce “expired” string when the value is negative.
I have the following added to an annotation:
{{ if lt $values.last.Value 0}}expired{{end}}
But it doesn’t work and I get the following error:
error executing template [snip]
at <lt $values.last.Value 0>: error calling lt: incompatible types for comparison"
On the other hand when I tried comparing values from two different expressions - it worked:
{{ if lt $values.now.Value $values.before.Value}}decreased{{end}}
But I can’t figure out how to compare a value and a constant.
(I also tried using “0” instead of 0 - but that didn’t help).