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:

Relabeled Object Type Configuration Section
Discovered scrape targets relabel_configs section in a scrape_config section
Discovered Alertmanager targets relabel_configs section in an alertmanager_config section
Individual samples from scrapes metric_relabel_configs section in a scrape_config section
Alerts sent to all Alertmanagers alert_relabel_configs section in the alerting section of the main configuration file
Alerts sent to a subset of Alertmanagers alert_relabel_configs section in an alertmanager_config section
Samples written to remote storage systems write_relabel_configs section in the remote_write section

Relabeling in the Prometheus architecture

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:

Relabeling flow

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).