Match addresses with or without declared ports.
This change updates port relabeling for pod and service discovery so the relabeling regex matches addresses with or without declared ports. As well, this change uses a consistent style in the replacement pattern for the two expressions. Previously, for both services or pods that did not have declared ports, the relabel config regex would fail to match: __meta_kubernetes_service_annotation_prometheus_io_port regex: (.+)(?::\d+);(\d+) __meta_kubernetes_pod_annotation_prometheus_io_port regex: (.+):(?:\d+);(\d+) Both regexes expected a <host>:<port> pattern. The new regex matches addresses with or without declared ports by making the :<port> pattern optional. __meta_kubernetes_service_annotation_prometheus_io_port __meta_kubernetes_pod_annotation_prometheus_io_port regex: (.+)(?::\d+)?;(\d+)
This commit is contained in:
parent
a37d39c463
commit
0b1790ee44
|
@ -108,7 +108,7 @@ scrape_configs:
|
|||
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
|
||||
action: replace
|
||||
target_label: __address__
|
||||
regex: (.+)(?::\d+);(\d+)
|
||||
regex: (.+)(?::\d+)?;(\d+)
|
||||
replacement: $1:$2
|
||||
- action: labelmap
|
||||
regex: __meta_kubernetes_service_label_(.+)
|
||||
|
@ -174,8 +174,8 @@ scrape_configs:
|
|||
regex: (.+)
|
||||
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
|
||||
action: replace
|
||||
regex: (.+):(?:\d+);(\d+)
|
||||
replacement: ${1}:${2}
|
||||
regex: (.+)(?::\d+)?;(\d+)
|
||||
replacement: $1:$2
|
||||
target_label: __address__
|
||||
- action: labelmap
|
||||
regex: __meta_kubernetes_pod_label_(.+)
|
||||
|
|
Loading…
Reference in New Issue