up metric relabel

24 views
Skip to first unread message

Kevin Black

unread,
Jul 7, 2020, 11:40:33 AM7/7/20
to Prometheus Users
Since the "up" metric is somewhat of a special case, does a metric_relabel_configs rule still apply to it? If not, is there a way to relabel those?  We attach a special label for items in certain namespaces, and I'd like to tag the up metric with the same label, but it does not seem to currently take. 


For my job scraping kubernetes pods, I have 

  metric_relabel_configs:
  - source_labels: [namespace]
    separator: ;
    regex: (.+)(-test$)
    target_label: foo
    replacement: ${1}
    action: replace


If I look at a list of metrics, I see the up metric does have the namespace label on it, but does not get the new foo label.  Other metrics scraped by the same job do, but the automatic prometheus metrics (i.e. up, scrape_duration_seconds, etc.) do not seem to get the needed label.

up{app="testfoo",component="test",instance="100.106.221.99:3000",job="kubernetes-pods",kubernetes_pod_name="testfoo-625644656d-pasp2",namespace="important-test",pod_template_hash="625458653a",release="testfoo"}    

Is there a way to force this label on these as well?

Ben Kochie

unread,
Jul 7, 2020, 11:43:15 AM7/7/20
to Kevin Black, Prometheus Users
No, for the up metric, it needs to be in the target `relabel_configs` phase.

For things like namespace, assuming this is Kubernetes, it comes from the k8s_sd_configs metadata.

--
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/1cace066-791f-4421-a3ca-9a866f72d6d7o%40googlegroups.com.

Kevin Black

unread,
Jul 9, 2020, 2:59:34 AM7/9/20
to Prometheus Users
Ah, that works perfectly.  Thanks Ben!


On Tuesday, July 7, 2020 at 11:43:15 AM UTC-4, Ben Kochie wrote:
No, for the up metric, it needs to be in the target `relabel_configs` phase.

For things like namespace, assuming this is Kubernetes, it comes from the k8s_sd_configs metadata.

On Tue, Jul 7, 2020 at 5:40 PM Kevin Black <kevinbla...@gmail.com> wrote:
Since the "up" metric is somewhat of a special case, does a metric_relabel_configs rule still apply to it? If not, is there a way to relabel those?  We attach a special label for items in certain namespaces, and I'd like to tag the up metric with the same label, but it does not seem to currently take. 


For my job scraping kubernetes pods, I have 

  metric_relabel_configs:
  - source_labels: [namespace]
    separator: ;
    regex: (.+)(-test$)
    target_label: foo
    replacement: ${1}
    action: replace


If I look at a list of metrics, I see the up metric does have the namespace label on it, but does not get the new foo label.  Other metrics scraped by the same job do, but the automatic prometheus metrics (i.e. up, scrape_duration_seconds, etc.) do not seem to get the needed label.

up{app="testfoo",component="test",instance="100.106.221.99:3000",job="kubernetes-pods",kubernetes_pod_name="testfoo-625644656d-pasp2",namespace="important-test",pod_template_hash="625458653a",release="testfoo"}    

Is there a way to force this label on these as well?

--
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 promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages