Search code examples
prometheusopen-telemetry-collector

prometheus relabel instance


I currently have this metric:

os_processor_information_processor_time_percent{instance="3,9"} 0.026940740009384623

I would like to change the labeling to be:

os_processor_information_processor_time_percent{instance="3,9",nodegroup="3",core="9"}

Is this possible?

I was trying to do this on prometheus side. But if doable on opentelemetry collector side, that would be fine too. I couldn't get it going with the metricstransform or the new ottl.


Solution

  • If you'd like to do this in the otelcollector, you can use the transform processor (docs here).

    If you'd like to do this in prometheus's scrape config, you can do this by using a metric_relabel_configs like so:

    metric_relabel_configs:
      - action: replace
        regex: "([0-9]+),[0-9]+"
        replacement: "${1}"
        separator: ";"
        source_labels:
        - instance
        target_label: nodegroup
      - action: replace
        regex: "[0-9]+,([0-9]+)"
        replacement: "${1}"
        separator: ";"
        source_labels:
        - instance
        target_label: core