In a json config file (referred to from file_sd_configs
), I have entries such as
[
...
"targets": [ "10.123.456.789"],
"labels": { "node_exporter_port": "9300" }
},
...
]
In Prometheus configuration, I'd like to relabel_configs
so that the value of __address__
is the current value of address plus the port. Attempts such as the following do not work:
relabel_configs:
- source_labels: [node_exporter_port]
regex: (.*)
target_label: __address__
replacement: [__address__]:${1}
EDIT: The following seems to work:
relabel_configs:
- source_labels: [__address__, node_exporter_port]
separator: ';'
regex: '(.*);(.*)'
target_label: __address__
replacement: ${1}:${2}
Is this idiomatic?
If you change the separator to colon you can remove the regex and replacement, as the defaults do what you need.
The port label should be prefixed with __ so that it doesn't end up as a target label.