How to use labels and annotations in description of alerting rule

Hello,

I created alerting rule with following description:

Current temperature in '{{ $labels.series }}, {{ $values._col1.labels }}, {{ $values._col1.labels.series }}' is '{{ $value }}, {{ $values._col1 }}, {{ $values._col1.value }}'.

I intentionally used multiple combinations. However it doesn’t work as variables series and value aren’t expanded in received email.

Description: Current temperature in '<no value>, <no value>, <no value>' is '[ metric='_col1' labels={series=living-room} value=24.214924 ], <no value>, <no value>'.

It seems like I’m doing something wrong or it doesn’t work as expected.
The output should looks like:

Description: Current temperature in 'living-room' is '24.214924'.

Value of variable $value is [ metric='_col1' labels={series=living-room} value=24.214924 ].

BTW I use timestream as data source.
Not sure it has any impact on it.

Does anybody know how to achieve it ?

Thx
BR

I figure it out ! :slight_smile:
I read documentation for annotations and labels for alerting rules before however I missed one important note. Variables $labels and $values are available only when you don’t use classic condition in Grafana alerting rule. I don’t know the reason behind it but It is a fact. Later I also found this discussion about similar issue.

2 Likes