What are `label_replace()` and `label_join()`?
IntermediateConceptPromQL & Recording Rules
Answer
They create or rewrite labels at query time with a regex:
label_replace(up, "host", "$1", "instance", "(.*):.*")
label_join(up, "target", "/", "job", "instance")
Useful to align labels before vector matching (for example instance with port vs node without). If you need it on every query, fix it in relabeling instead.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate