Help with understanding relabel config

66 views
Skip to first unread message

Tomer Leibovich

unread,
Jun 8, 2020, 11:53:25 AM6/8/20
to Prometheus Users
Hi,

I'm monitoring my K8s environment using prometheus-operator chart.
I'm trying to understand how can I drop certain metrics, for example, if I do 
kube_pod_info{namespace="monitoring"}
I will have the following output:

kube_pod_info{created_by_kind="DaemonSet",created_by_name="prom-operator-prometheus-node-exporter",endpoint="http",host_ip="192.168.83.60",instance="10.133.86.207:8080",job="kube-state-metrics",namespace="monitoring",node="node2",pod="prom-operator-prometheus-node-exporter-nrck9",pod_ip="192.168.83.60",service="prom-operator-kube-state-metrics",uid="ecd029bf-e998-4b7b-a0dc-7eeefec25668"}

So I'm trying to understand how I can drop from here the UID part.

I've tried creating the following relabel_config:
    relabelings:
    - sourceLabels: [uid]
      action: drop

It did nothing.
Also, I've tried:
- action: drop
regex: 'uid.+'
sourceLabels: [uid]

And this did nothing as well...

Any help to understand it will be very much appreciated.


Stuart Clark

unread,
Jun 8, 2020, 12:28:34 PM6/8/20
to Tomer Leibovich, Prometheus Users

The drop action is to drop whole metrics. You want labeldrop. You are also missing the "regex" parameter.

https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config


-- 
Stuart Clark

Ben Kochie

unread,
Jun 8, 2020, 5:12:08 PM6/8/20
to Stuart Clark, Tomer Leibovich, Prometheus Users
When using action: drop:

relabel_configs drop targets before they are scraped

metric_relabel_configs drop metrics after they are scraped

If the `uid` label comes from the target, you need to use metric_relabel_configs.

--
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/c99438f0-5274-a42f-2e70-fb224b24db87%40Jahingo.com.

Tomer Leibovich

unread,
Jun 10, 2020, 8:42:35 AM6/10/20
to Prometheus Users
Thanks Stuart and Ben,

Can you provide an example on how to drop the specific label from the metric?
It's not so clear from the docs on how it should be done.

So, if I understand it correctly, the metric label is kube_pod_info, inside of it, the field UID is another label that I can drop using labeldrop?

Tomer Leibovich

unread,
Jun 17, 2020, 3:26:51 AM6/17/20
to Prometheus Users
Nothing?
Any help?
Reply all
Reply to author
Forward
0 new messages