Mazzy
Mazzy

Reputation: 14189

Relabeling instance name in prometheus

I'm trying to relabel the __address__ property in Prometheus without any luck. This is my configuration:

      - job_name: 'kafka'
        scrape_interval: 10s
        static_configs:
          - targets:
            - kafka-kafka-0.kafka-kafka-headless:5556
            - kafka-kafka-1.kafka-kafka-headless:5556
            - kafka-kafka-2.kafka-kafka-headless:5556
            - kafka-kafka-3.kafka-kafka-headless:5556
            - kafka-kafka-4.kafka-kafka-headless:5556
            - kafka-kafka-5.kafka-kafka-headless:5556
        relabel_configs:
          - source_labels: [__address__]
            regex: '(.+)\.'
            target_label: instance
            replacement: ${1}

What I'm trying to achieve is to take address label and make the instance label like kafka-kafka-0, kafka-kafka-1, etc... but it doesn't work as expected

Upvotes: 1

Views: 5152

Answers (1)

brian-brazil
brian-brazil

Reputation: 34142

Prometheus regexes are anchored, so your regex doesn't match. Add .* at the end.

Upvotes: 3

Related Questions