Refine functions.md as suggested during review
See https://github.com/prometheus/prometheus/pull/11404#issuecomment-1631165746 Signed-off-by: Guillaume Berche <guillaume.berche@orange.com>
This commit is contained in:
parent
e6b84ac1e0
commit
60b380da70
|
@ -289,7 +289,7 @@ 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 value of the label `src_label`. If it
|
||||
matches the [regular expression](https://github.com/google/re2/wiki/Syntax) `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. Named capturing groups in the regular expression can be referenced with `$name` (where `name` is the capturing group name). If the regular expression doesn't match then the timeseries is returned unchanged.
|
||||
|
@ -300,6 +300,10 @@ This example will return timeseries with the values `a:c` at label `service` and
|
|||
label_replace(up{job="api-server",service="a:c"}, "foo", "$1", "service", "(.*):.*")
|
||||
```
|
||||
|
||||
This second example has the same effect than the first example, and illustrates use of named capturing groups:
|
||||
```
|
||||
label_replace(up{job="api-server",service="a:c"}, "foo", "$name", "service", "(?P<name>.*):(?P<version>.*)")
|
||||
```
|
||||
## `ln()`
|
||||
|
||||
`ln(v instant-vector)` calculates the natural logarithm for all elements in `v`.
|
||||
|
|
Loading…
Reference in New Issue