External Labels not accessible in alert rules.

43 views
Skip to first unread message

Sohaib Omar

unread,
Apr 10, 2020, 7:30:50 AM4/10/20
to Prometheus Users
Hi,
I have set external labels as below in my Prometheus configuration.
externalLabels:
    deployment_env: dev
    org_id: myOrganization
...


and in my rules.yaml I am trying to access external labels like below.
- alert: ClusterCapacityWarning
annotations:
summary: "Available capacity of cluster on {{ $externalLabels.deployment_env }} is Low."
description: "Capacity of cluster {{ $externalLabels.org_id }} is less than 20%."
expr: |
(cluster_resource_capacity_available < 20)
for: 5m
labels:
severity: warning

but doing above I get the error function externalLabels.deployment_env not found

what am I doing wrong? Have anyone been in a similar situation before?

Even in Prometheus docs states that The configured external labels can be accessed via the $externalLabels variable.

Thanks

Julius Volz

unread,
Apr 10, 2020, 2:46:48 PM4/10/20
to Sohaib Omar, Prometheus Users
Hi,

Are you using a recent version of Prometheus? Being able to access external labels from alert templates was added in https://github.com/prometheus/prometheus/pull/5463 a year ago (see https://github.com/prometheus/prometheus/blob/master/CHANGELOG.md#2100--2019-05-25).

Cheers,
Julius

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/5564e9e3-d49a-4af7-b7fa-074a81036382%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages