Prometheus ignore metric by name from target scraping?

  • What Grafana version and what operating system are you using?
    Docker image: prom/prometheus:v2.51.2
    OS: Ubuntu 22.04

  • What are you trying to achieve?
    I want to drop specific metrics so they don’t get ingested into prometheus.

  • How are you trying to achieve it?
    Thats the config:

scrape_configs:
- job_name: bamboo
  metrics_path: /bamboo/plugins/servlet/prometheus/metrics
  scheme: https
  static_configs:
  - targets:
    - redacted.com
  metric_relabel_configs:
  - source_labels: [__name__]
    regex: bamboo_build_*
    action: drop

I tried metric_label_configs and relabel_configs:

  relabel_configs:
  - action: labeldrop
    regex: bamboo_build_duration_histogram_bucket
  • What happened?
    The metric is still processed by prometheus and also accessable in grafana.

  • What did you expect to happen?
    It should not be acessable in grafana.

  • Can you copy/paste the configuration(s) that you are having problems with?
    See above

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors in prometheus or grafana.

  • Did you follow any online instructions? If so, what is the URL?
    Reduce metrics costs by filtering collected and forwarded metrics | Grafana Cloud documentation

i was actually quite close!

Thats the working config now:

scrape_configs:
- job_name: bamboo
  metrics_path: /bamboo/plugins/servlet/prometheus/metrics
  scheme: https
  static_configs:
  - targets:
    - redacted.com
  # Relabeling rules to ignore specific metrics
  metric_relabel_configs:
    - source_labels: [__name__]
      regex: 'bamboo_build.*'  # Regular expression matching the metrics you want to ignore
      action: drop  # Action to perform (in this case, drop the matching metrics)