Merge pull request #447 from pedro-stanaka/feat/doc-special-regex-match

Adding documentation about special regex match group
This commit is contained in:
Matthias Rampke 2022-07-08 10:59:00 +00:00 committed by GitHub
commit 9115f0fa39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -317,6 +317,27 @@ 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).
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/444).
### Naming, labels, and help
Please note that metrics with the same name must also have the same set of