mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -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()`
|
## `label_replace()`
|
||||||
|
|
||||||
For each timeseries in `v`, `label_replace(v instant-vector, dst_label string,
|
For each timeseries in `v`, `label_replace(v instant-vector, dst_label string, replacement string, src_label string, regex string)`
|
||||||
replacement string, src_label string, regex string)` matches the regular
|
matches the regular expression `regex` against the value of the label `src_label`. If it
|
||||||
expression `regex` against the label `src_label`. If it matches, then the
|
matches, the value of the label `dst_label` in the returned timeseries will be the expansion
|
||||||
timeseries is returned with the label `dst_label` replaced by the expansion of
|
of `replacement`, together with the original labels in the input. Capturing groups in the
|
||||||
`replacement`. `$1` is replaced with the first matching subgroup, `$2` with the
|
regular expression can be referenced with `$1`, `$2`, etc. If the regular expression doesn't
|
||||||
second etc. If the regular expression doesn't match then the timeseries is
|
match then the timeseries is returned unchanged.
|
||||||
returned unchanged.
|
|
||||||
|
|
||||||
This example will return a vector with each time series having a `foo`
|
This example will return timeseries with the values `a:c` at label `service` and `a` at label `foo`:
|
||||||
label with the value `a` added to it:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
label_replace(up{job="api-server",service="a:c"}, "foo", "$1", "service", "(.*):.*")
|
label_replace(up{job="api-server",service="a:c"}, "foo", "$1", "service", "(.*):.*")
|
||||||
|
|
Loading…
Reference in a new issue