Vova Rozhkov
Vova Rozhkov

Reputation: 1732

How to concatenate labels in Prometheus relabel config

I have a fleet of EC2 instances and want to relabel their prometheus names to be like: ${__meta_ec2_tag_Name}:${__meta_ec2_private_ip} so my relabeled name will look like portal-service:10.0.19.98.

I'm understand how to relabel a single label using regex, but don't know how to use a several source labels.

My current config relabel instance name to private ip, but I want to add something else (and perhaps more than one keys) to it:

  relabel_configs:
    - source_labels: ['__meta_ec2_private_ip']
      target_label: 'instance'

Upvotes: 2

Views: 4341

Answers (1)

brian-brazil
brian-brazil

Reputation: 34122

All source labels are concatenated by semicolon by default, but it can be changed:

source_labels: ['__meta_ec2_tag_Name', '__meta_ec2_private_ip']
separator: ':'
target_label: instance

Upvotes: 10

Related Questions