diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 16a440165f..848908ca90 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -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", "(.*):.*")