Relabeling Overview
Relabeling is implemented as a series of transformation steps that you can apply in different sections of the Prometheus configuration file to filter or modify a list of labeled objects. You can apply relabeling to the following types of labeled objects:
- Discovered scrape targets (
relabel_configs
section in ascrape_config
section). - Individual samples from scrapes (
metric_relabel_configs
section in ascrape_config
section). - Alerts sent to the Alertmanager (
alert_relabel_configs
section in thealertmanager_config
section). - Samples written to remote storage systems (
write_relabel_configs
section in theremote_write
section).
All of these different relabeling configuration sections are of the same type relabel_config
.
A relabeling configuration section consists of a list of rules that are applied in sequence to each labeled object. Each rule in the chain may either modify or drop a labeled object:
For example, a relabeling rule may keep or drop an object based on a regular expression match, may modify its labels, or may map a whole set of labels to another set. Once a relabeling step decides to drop a labeled object, no further relabeling steps are executed for this object and it is deleted from the output list (for example, for a target, this would mean it will not be scraped).