From f935a9c86920a1cec5ceb652bd25004a9b0ba326 Mon Sep 17 00:00:00 2001 From: Pedro Tanaka Date: Wed, 29 Jun 2022 10:14:56 +0200 Subject: [PATCH 1/3] Adding documentation about special regex match group Signed-off-by: Pedro Tanaka --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 67ca0b0..55bac74 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,25 @@ mappings: provider: "$1" ``` +#### Special match groups + +When using regex, the match group `0` is the full match and can be used to attach labels to the metric. +Example: + +```yaml +mappings: +- match: ".+" + match_type: regex + name: "$0" + labels: + statsd_metric_name: "$0" +``` + +If a metric `my.statsd_counter` is received, the metric name will **still** be mapped to `my_statsd_counter` (Prometheus compatible name). +But the metric will also have the label `statsd_metric_name` with the value `my.statsd_counter` (unchanged value). + +The same is not achievable with glob matching, for more details check [this issue](https://github.com/prometheus/statsd_exporter/issues/438). + ### Naming, labels, and help Please note that metrics with the same name must also have the same set of From 1a148215deffacc07c1ae656639a57f8fcaf4d26 Mon Sep 17 00:00:00 2001 From: Pedro Tanaka Date: Wed, 29 Jun 2022 10:18:15 +0200 Subject: [PATCH 2/3] Adding note about behavior of .+ regex Signed-off-by: Pedro Tanaka --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 55bac74..189e754 100644 --- a/README.md +++ b/README.md @@ -334,6 +334,8 @@ mappings: If a metric `my.statsd_counter` is received, the metric name will **still** be mapped to `my_statsd_counter` (Prometheus compatible name). But the metric will also have the label `statsd_metric_name` with the value `my.statsd_counter` (unchanged value). +Note: If you use the `match` like the example (i.e. `.+`), be aware that it will be a "catch-all" block. So it should come at the very end of the mapping list. + The same is not achievable with glob matching, for more details check [this issue](https://github.com/prometheus/statsd_exporter/issues/438). ### Naming, labels, and help From 6ef0b3b4e87ed9f40ca6f5bfaf89bf5922ecb805 Mon Sep 17 00:00:00 2001 From: Pedro Tanaka Date: Wed, 29 Jun 2022 10:23:33 +0200 Subject: [PATCH 3/3] Changing issue number for tracking support for globbling Signed-off-by: Pedro Tanaka --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 189e754..110a7d0 100644 --- a/README.md +++ b/README.md @@ -336,7 +336,7 @@ But the metric will also have the label `statsd_metric_name` with the value `my. Note: If you use the `match` like the example (i.e. `.+`), be aware that it will be a "catch-all" block. So it should come at the very end of the mapping list. -The same is not achievable with glob matching, for more details check [this issue](https://github.com/prometheus/statsd_exporter/issues/438). +The same is not achievable with glob matching, for more details check [this issue](https://github.com/prometheus/statsd_exporter/issues/444). ### Naming, labels, and help