mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Merge pull request #8765 from SmedbergM/label-replace-docs
docs :: querying :: functions :: label_replace
This commit is contained in:
commit
202446955a
|
@ -280,16 +280,14 @@ label_join(up{job="api-server",src1="a",src2="b",src3="c"}, "foo", ",", "src1",
|
|||
|
||||
## `label_replace()`
|
||||
|
||||
For each timeseries in `v`, `label_replace(v instant-vector, dst_label string,
|
||||
replacement string, src_label string, regex string)` matches the regular
|
||||
expression `regex` against the label `src_label`. If it matches, then the
|
||||
timeseries is returned with the label `dst_label` replaced by the expansion of
|
||||
`replacement`. `$1` is replaced with the first matching subgroup, `$2` with the
|
||||
second etc. If the regular expression doesn't match then the timeseries is
|
||||
returned unchanged.
|
||||
For each timeseries in `v`, `label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)`
|
||||
matches the regular expression `regex` against the value of the label `src_label`. If it
|
||||
matches, the value of the label `dst_label` in the returned timeseries will be the expansion
|
||||
of `replacement`, together with the original labels in the input. Capturing groups in the
|
||||
regular expression can be referenced with `$1`, `$2`, etc. If the regular expression doesn't
|
||||
match then the timeseries is returned unchanged.
|
||||
|
||||
This example will return a vector with each time series having a `foo`
|
||||
label with the value `a` added to it:
|
||||
This example will return timeseries with the values `a:c` at label `service` and `a` at label `foo`:
|
||||
|
||||
```
|
||||
label_replace(up{job="api-server",service="a:c"}, "foo", "$1", "service", "(.*):.*")
|
||||
|
|
Loading…
Reference in a new issue