Fix regex for blackbox exporter targets

Fixes the regex used to match blackbox exporter targets in the
prometheus.yml.j2 template to be less strict. Previously we were using
\w which did not allow for names with periods or hyphens.

Closes-Bug: #2098511
Change-Id: I3ac18bd12ed1dceef206040b3e793faa79717a19
This commit is contained in:
Dawud
2025-02-13 19:15:06 +00:00
parent b076618aae
commit 62c07e73dc
2 changed files with 10 additions and 3 deletions

View File

@@ -178,17 +178,17 @@ scrape_configs:
{% endfor %}
relabel_configs:
- source_labels: [__address__]
regex: (\w+):(\w+):(.+)
regex: ([^:]+):([^:]+):(.+)
target_label: service
replacement: ${1}
- source_labels: [__address__]
regex: (\w+):(\w+):(.+)
regex: ([^:]+):([^:]+):(.+)
target_label: __param_module
replacement: ${2}
- source_labels: [__param_module]
target_label: module
- source_labels: [__address__]
regex: (\w+):(\w+):(.+)
regex: ([^:]+):([^:]+):(.+)
target_label: __param_target
replacement: ${3}
- source_labels: [__param_target]

View File

@@ -0,0 +1,7 @@
---
fixes:
- |
Fixes the regex used to match blackbox exporter targets in the
``prometheus.yml.j2`` template to be less strict. Previously we were using
``\w`` which did not allow for names with periods or hyphens. The service
and module labels can now contain all characters except for a colon.