I'm trying to add a new label with regex.
the name instance is pr-na01-na02-A
I'm trying to get only the pr-na01
,
so I did this:
- source_labels: ['__meta_ec2_tag_Name']
regex: '^[^-]*-[^-]*'
target_label: 'test'
replacement: '$1'
and still don't see a new label (test) under Prometheus metrics.
The issue is that you have no capture groups, so
$1
is empty. Also you're not matching the full string.Try
(^[^-]*-[^-]*).*
as the regex.