Add metric label based on Kubernetes Namespace metadata
39 views
Skip to first unread message
Joshua Branham
unread,
Nov 1, 2020, 11:48:07 AM11/1/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
Anyone know of a way to add a label to all metrics that is the value of a label on the Kubernetes namespace of the incoming alert? for example, setting a label 'team_name' automatically for the metric kube_pod_container_status_restarts_total based on the value of 'team_name' on the namespace metadata. The goal is to find some way to dynamically decide what receiver to send an alert to based on metadata from k8s rather than explicitly defining it in the alertmanager config.
Brian Candler
unread,
Nov 1, 2020, 3:39:52 PM11/1/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
If you have one timeseries kube_pod_container_status_restarts_total, and another timeseries which has a 'team_name' label, and there is some common label between the two (pod id?), then you can join them in your alerting rule expr so that the PromQL result includes the 'team_name' label.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prometheus Users
Thanks for the info, yeah I was hoping to do this all on the alertmanager side if I could. We use a lot of rules from this upstream and I was hoping to not have to modify them just to get this to work https://github.com/kubernetes-monitoring/kubernetes-mixin