Alert rule summary - Labels/annotations for multiple results

Hello

I’m trying to set up an alert rule for % free space in Grafana using % free space from Windows performance counters gathered by Telegraf and saved in to Influx.

I am running a query (A) to gather the % free space for each disk on each server in our environment. An expression (B) then evaluates whether each value returned by query A is less than 20 using a classic condition.

The question I have is: As there will potentially be more than one disk with less than 20% free space, is there an elegant way of generating a summary for the alert?

I’m currently using these labels/annotations in the alert summary field:

{{ if $values.B0 }} Disk {{ $values.B0.Labels.instance }} on server {{ $values.B0.Labels.host}} has less than 20% free space remaining {{ end }}
{{ if $values.B1 }} Disk {{ $values.B1.Labels.instance }} on server {{ $values.B1.Labels.host}} has less than 20% free space remaining {{ end }}
{{ if $values.B2 }} Disk {{ $values.B2.Labels.instance }} on server {{ $values.B2.Labels.host}} has less than 20% free space remaining {{ end }}

This gives the output below (which is desired):

Disk C: on server SERVER01 has less than 20% free space remaining
Disk C: on server SERVER02 has less than 20% free space remaining
Disk C: on server SERVER03 has less than 20% free space remaining

I had tried using $values.B. in the above lines, but this doesn’t work.

Any advice would be very much appreciated.

1 Like