Relabeling - drop all except

37 views
Skip to first unread message

Jimmy the Greek

unread,
Dec 10, 2020, 5:37:59 PM12/10/20
to Prometheus Users
Looking to use relabeling with remote_write to limit metrics forwarded to remote endpoint.

The following guide shows some examples:

https://medium.com/quiq-blog/prometheus-relabeling-tricks-6ae62c56cbda

What I am looking to do is forward only metrics from a specific job and drop everything else. Seeing as I don't want to have to update the config every time a new job is added to exclude that is it possible to have a default rule that if not matched drops the metrics.

Something like

metric_relabel_configs:
- source_labels: [job]
  regex: 'ambassador'
  action: keep 
- source_labels: [job]
  regex: '.+'
  action: drop

Does Prometheus stop evaluating the rules after the first one matches or will it end up matching both rules. 

Brian Brazil

unread,
Dec 10, 2020, 5:41:53 PM12/10/20
to Jimmy the Greek, Prometheus Users
On Thu, 10 Dec 2020 at 22:38, Jimmy the Greek <matthe...@gmail.com> wrote:
Looking to use relabeling with remote_write to limit metrics forwarded to remote endpoint.

The following guide shows some examples:

https://medium.com/quiq-blog/prometheus-relabeling-tricks-6ae62c56cbda

What I am looking to do is forward only metrics from a specific job and drop everything else. Seeing as I don't want to have to update the config every time a new job is added to exclude that is it possible to have a default rule that if not matched drops the metrics.

Something like

metric_relabel_configs:
- source_labels: [job]
  regex: 'ambassador'
  action: keep 

This action is sufficient, anything not kept will be dropped.

Brian
 
- source_labels: [job]
  regex: '.+'
  action: drop

Does Prometheus stop evaluating the rules after the first one matches or will it end up matching both rules. 

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/e85cc082-b0d0-47f0-834e-a6914c9470f1n%40googlegroups.com.


--
Reply all
Reply to author
Forward
0 new messages