Adding documentation about special regex match group

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
This commit is contained in:
Pedro Tanaka 2022-06-29 10:14:56 +02:00
parent 848212e028
commit f935a9c869

View file

@ -317,6 +317,25 @@ mappings:
provider: "$1" 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 ### Naming, labels, and help
Please note that metrics with the same name must also have the same set of Please note that metrics with the same name must also have the same set of