bschaeffer
bschaeffer

Reputation: 2904

relabeling/metricRelabeling to drop and filter by labels

I am having no luck configuring prometheus relabeling. If I have series like

some_metric{app="foo",baz="true"}
some_metric{app="bar",baz="true"}

How do I configure prometheus (currently using the coreos operator if that matters), to keep only app=foo and drop the label baz, so that I end up with:

some_metric{app="foo"}

For what it's worth, here's what I currently have and the labels are showing up as is:

- action: keep
  sourceLabels: ["app"]
  regex: "foo"
- action: labeldrop
  regex: "baz"

Upvotes: 3

Views: 6338

Answers (1)

trallnag
trallnag

Reputation: 2376

This should work:

metric_relabel_configs:
- action: labeldrop
  regex: baz
- action: drop
  source_labels: [app]
  regex: bar

Upvotes: 0

Related Questions