Hi!

I was trying to use metric_relabel_configs in order to change the label
content (sourcing from another label) of a metric.

The original metric looks like this:

collectd_openstack_nova_gauge{exported_instance="site1-director.potato.com
",instance="123.123.123.123:9103",job="collectors",openstack_nova="
hypervisor-site1-compute001.potato.com
",role="Director",short_hostname="director",site="site1",tripleo_role="Director",type="hypervisor_version"}

In our case, because we are scraping a central endpoint, our short_hostname
will carry the label of the actual scraped target. Ideally, I would want
short_hostname to be changed to qasite1-compute001.

I've tried using the following metric_relabel_configs, but while it doesn't
break anything, it doesn't seem to change the labels when looking at
Prometheus.

    metric_relabel_configs:
      # Change the nova metric short_hostname to the compute name.
      - source_labels: ["openstack_nova"]
        regex: '([a-z]+.-compute\d\d\d)'
        target_label: "short_hostname"
        action: replace
        replacement: "$1"

This is placed within the job block that contains that scrape job.

Anything else I would need to double-check here? The Regex seems ok
according to RE2 parsers, the syntax seems correct as well.

Thanks!

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAOAKi8wstMVM7fZ%2Ba-bCLMd%3DvQAXPRj5EgqqkNnphAEkumYe1w%40mail.gmail.com.

Reply via email to