Hi.
Is it possible to replace certain char in label?
I have a metric like this:
my_metric{label1=“foo-foo-foo”, label2=“foo”}
label1 may have values:
foo
foo-foo
foo-foo-foo
and so on
It isn’t known how many ‘-’ it has.
I want to replace all dashes with underscore in label1 value:
my_metric{label1=“foo_foo_foo”, label2=“foo”}
Again, i don’t know how many dashes it may has.
I tried using “metric_relabel_configs” with replace mechanism, but it seems not possible to do with that.
>If it's someone else's exporter - then use the labels as they are.
it isn't possible because they use label as part of the metric name with '_'
Thank you, it works, but with minor fix with your code
- source_labels: [ label1 ]
target_label: label1
regex: '([[:alnum:]]+)[-_]+([[:alnum:]]+)'
replacement: "${1}_${2}"
From exporter:
pooler_my_db_name_query_count{<many labels>} it doesn't have label for databasename, the databasename is in metric name but all '-' replaced with '_'