1

For example, I have teo metrics with different label

node_metrics_first{foo="bar",AAA="aaa"}
node_metrics_second{BBB="bbb",CCC="ccc"}

how can I use relabeling/metricRelabeling drop/labeldrop in servicemonitor to remove foo label in node_metrics_first, which means I should get the result:

node_metrics_first{AAA="aaa"}
node_metrics_second{BBB="bbb",CCC="ccc"}

Itay Grudev
  • 7,055
  • 4
  • 54
  • 86
chocho li
  • 11
  • 2

2 Answers2

0

In Prometheus operator ServiceMonitors, you can use spec.endpoints[*].relabelings to alter labels and metrics:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
spec:
  endpoints:
  - interval: 30s
    port: metrics
    scheme: http
    relabelings:   <-- here you shine!
    - action: labeldrop
      regex: (foo|otherlabeltodrop)
Aref Riant
  • 582
  • 3
  • 14
-1

There is an extensive blog from Grafana about how the relabeling works. In your case:

  - job_name: some_job
    metric_relabel_configs:
      - regex: "foo"
        action: labeldrop
Rick Rackow
  • 1,490
  • 8
  • 19