Understanding of relabel config and metric_label_config

111 views
Skip to first unread message

akshay sharma

unread,
Jul 13, 2021, 2:49:47 AM7/13/21
to Prometheus Users
Hi,

I'm trying to drop metrics with specific label values for ex:

node_network_up{device="d0",instance="xxx",job="Node-1"}0
node_network_up{device="x160",instance="xxx",job="Node-1"}1
node_network_up{device="x192",instance="xxx",job="Node-1"}0
node_network_up{device="d1",instance="xxx",job="Node-1"}0
node_network_up{device="l0",instance="xxx",job="Node-1"}
node_network_up{device="k0",instance="xxx",job="Node-1"}
node_network_up{device="a0",instance="xxx",job="Node-1"}


I want to drop metrics which has a device name apart from x160,x192,d1,d0.

Note: I've tried added relabel_config as below, but it is not working(when giving regex or any generic command).
metric_relabel_configs:
  - source_labels: [__name__,device]
    regex: node_network_up; (x|d).+
    action: drop

- source_labels: [__name__,device]
    regex: node_network_up; d*
    action: drop

This is working
- source_labels: [__name__,device]
    regex: node_network_up; d1
    action: drop



When I tried below configuration, all metrics are coming as empty, no data can be shown in prometheus. 
metric_relabel_configs:
  - source_labels: [__name__, device]
    regex: "node_network_up;(x|d).+"
    action: keep


When i tried below configuration, even the target is not showing in prometheus target option.
relabel_config: 
- source_labels: [__name__, device]
    regex: "node_network_up;(x|d).+"
    action: keep

Can you please put some light on relabel config and metric relabel config. And why am I facing the issues mentioned above?

thanks
,
Akshay
Reply all
Reply to author
Forward
0 new messages