file_sd_configs and renaming mertics

34 views
Skip to first unread message

Hossman12

unread,
Jun 4, 2020, 2:03:51 PM6/4/20
to Prometheus Users
I'm using file_sd_configs on my remote prometheus instances nad they are being federated into a central location.   The federation job currently filters out all the "go" metrics.  I have an application team that wants to rename the "go" metrics to say "app_go..."  so that they will be federated up for their specific application.  I cannot remove the filter at the fedration level due to the negative impact on the enviorment.  

Christian Hoffmann

unread,
Jun 4, 2020, 4:04:52 PM6/4/20
to Hossman12, Prometheus Users
Hi,
Basically this sounds like it could work using metric_relabel_configs.
However, it also sounds like an anti-pattern, both the "let's federate
(almost) everything" part and the "let's find a workaround for a
specific team".

Maybe you should look into empowering the team to work with "their"
Prometheus instance and try to keep the federated metrics at a minimum
(meta monitoring, job-level stuff)?

Kind regards,
Christian

signature.asc

Hossman12

unread,
Jun 19, 2020, 5:05:36 PM6/19/20
to Prometheus Users
So I have a working config renaming the metrics in the job in my main yaml file.    Is it possible to put this in file_sd_config file?

    metric_relabel_configs:
# Rewrite the Metric Name pre-pending a new prefix
      - source_labels: [__name__]
        regex: "(^targetmetric_.*)"
        target_label: "__name__"
        replacement: "new_prefix_$1"

Brian Candler

unread,
Jun 20, 2020, 4:45:18 AM6/20/20
to Prometheus Users
No. The actual file_sd targets file contains only targets and labels:
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config

The relabelling goes in the scrape job in the main prometheus config file.
Reply all
Reply to author
Forward
0 new messages