I have an alert with two queries, two reduced expressions C and D on queries A and B. In math expression E, which is checking if C and D are greater than 90.
In the alert description, I want to get a value of C when C is greater than 90 and value of D when its greater than 90 . Is it possible to use if else condition in the alert description?
Here if I use {{ $value }}, I get values in the string for C and D, I only want a value of C or D if any of them is greater than 80. can I use the If condition in the description any idea? please help me.
Hi @mahmed,
Calling variable {{ $values }} will always print all values, however you can do something like this for showing value C only if it is greater than 90:
{{ if (ge $values.C.Value 90.0) }}Not OK: Value C: {{ $values.C.Value }}{{ else }}Value C is OK.{{ end }}
Â
Breakdown: {{ if (ge $values.C.Value 90.0) }}
defines you condition (i.e. if C is greater than 90.0 then it will output true and will enter condition)
ge = greater or equal
 Not OK: Value C: {{ $values.C.Value }}
This will be printed if condition is met (i.e. C>=90.0)
{{ $values.C.Value }} will print value of C (e.g. 92.81231)
 Value C is OK.
This will be printed if condition is not met (i.e. C<90.0)
Â
{{ $labels.DBInstanceIdentifier }} can be used only if you see label/tag on alert rule (e.g. like cpu or host on picture above). However, I can see that you have DBInstanceIdentifier inside query C and query D so you can use next format to fetch value desired value: