Fetch RefID names from value string

Hello. I need to fetch the names of RefIDs.

Value: [ var='reduceA' labels={id=9} value=139000 ], [ var='reduceB' labels={id=9} value=139000 ], [ var='Change' labels={id=9} value=0 ], [ var='Final' labels={id=9} value=1 ]

I need to fetch ‘reduceA’, ‘reduceB’, ‘Change’ and ‘Final’ respectively and on the basis of that choose what to send as output. I am trying to do this per rule, by adding it under Summary and Annotations. Following this answer from community. Please help!

Grafana version: 9.2.3 open source
This is what is in my annotations for now -

{{ with $values }}
{{ range $k, $v := . }}
  Resource ID: {{ $v.Labels.id }}
  Alerting value: {{ $v }}
{{ end }}
{{ end }}

Also, my rule has Math and Reduce operations. And the above value snippet is of those expressions.

Hi! The Ref ID for each value (i.e. reduceA, reduceB, …) is $k in the range.

1 Like