Alert description with if else condition

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 }}


{{ 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)

{{ end }}

  • ends if condition


Best regards,


Hi @ldrascic , Thank you so much. I got the desired Alert description.

testing-New-Licensing RDS DB Connections HIGH {{ if (ge $values.C.Value 20.0) }} Value: {{ humanize $values.C.Value }} {{ else }} {{ humanize $values.D.Value }} {{ end }}

I want to get “DBInstanceIdentifier” in the alert description, but I am not able to achieve the desired output.

testing-New-Licensing RDS DB Connections HIGH {{ if (ge $values.C.Value 20.0) }} Value: {{ humanize $values.C.Value }} {{ else }} {{ humanize $values.D.Value }} {{ end }} on DBInstanceIdentifier: {{ $labels.DBInstanceIdentifier }}


I am not sure what I am doing wrong? sorry for silly query I am still learning .

Hi @mahmed,

Can you chech if DBInstanceIdentifier shows up as a label/tag on alert rule?


{{ $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:

{{ $values.C.Labels.DBInstanceIdentifier }}

Best regards,

Thank you so much for the solution. I break my mind about one week how to do this.

For me: I Have router and making the status for interfaces, when value != 1 Link UP, any other = Link down.

{{ if (ne $values.B.Value 1.0) }}:red_circle: Link Down :red_circle:{{ else }}:green_circle: Link UP :green_circle:{{ end }}

I use Telegram notifications
Screenshot from 2023-06-14 12-00-05