Capture Alerting Metric details in Alert Name/Rule Name

Hello Everyone,

Was hoping if I could get some assistance on this specific query.

I am trying to fetch value of “” and pass it within Custom Labels

[ var=‘C’ labels={,} value=1 ], [ var=‘B’ labels={,} value=35 ]

I’ve tried using

{{ $ }} but that’s not passing any value.

Was hoping if someone could assist



Maybe try this?

{{ $ }}

Thanks @grant2 ,

Tried that - i am still getting “no value” , I’ve tried using {{ $ }} in the past for the info where value was saved in “app” field - This time since the value is in “” it’s unable to capture value.


Can you (just for test purposes) create a label that does not have dots in the name and see if that works?

This info below is from our resident expert @melori.arellano in another post, but may be applicable here…

Examples for specific situations like . . .

When a label has dots in the name

If you have a label like netflow.ipv4_dst_addr with a value of, you might find that your alert template just shows the raw template (which is what happens if there’s an error in the evaluation).

If you’re using a classic condition, here’s an example of using the go index function:

{{ index $values.B0.Labels “netflow.ipv4_dst_addr” }}

Screen Shot 2022-08-15 at 6 15 21 PM

if your alert has two or more conditions or an expression, then you can use the $labels variable:
{{ index $labels “netflow.ipv4_dst_addr” }}

Screen Shot 2022-08-15 at 6 11 25 PM

Hi @grant2 ,

Please find below screenshots from another Alert - which was setup using Prometheus as a Datasource - which worked fine with {{ $labels.queue }}


The issue i am experiencing with has Google Cloud Monitoring Datasource. that’s where i have fields with “dots”

In both cases i’ve used Reduce and Maths to split alerts. However, one is behaving differently at the time of capturing values from Labels.

Just checking,

Has anyone found a solution to this?


@Rohan can you try something like this? I used a dummy test datasource and gave it one of your test labels with dots in the name. Then, I set the value of to slack.

Then I set the custom label to a value of {{index $labels ""}}

My default notification policy is email. To test that the label is working. I created a rule to route alerts with to my slack contact point overriding the default:

1 Like

Thanks @melori.arellano, the Rule is working for a Math expression -
However for Classic condition where it says “{{ index $values.B0.Labels “netflow.ipv4_dst_addr” }}” based on the example shared by @grant2 - I have two queries and an Expression which is a Classic condition

[ var=‘C0’ metric=‘abcd’ labels={,} value=3 ], [ var=‘C1’ metric=‘abcd-2’ labels={,} value=3 ], [ var=‘C2’ metric=‘abcd-3’ labels={,} value=2 ], [ var=‘C3’ metric=‘abcd-4’ labels={,} value=3 ], [ var=‘C4’ metric=‘abcd-5’ labels={,} value=3 ], [ var=‘C5’ metric=‘abcd-6’ labels={,} value=3 ], [ var=‘C6’ metric=‘abcd-7’ labels={,} value=2 ], [ var=‘C7’ metric=‘abcd-8’ labels={,} value=2 ]


Tried 2nd Approach too of using: {{ index $labels “” }} but it returns blank

Expectation is to capture all the labels within the label instead of just one.

@melori.arellano - whenever you get a chance would appreciate if you could look that there’s something i’ve missed?

Data source i am using is “Google Cloud Monitoring”