scrape rule drop all metrics except a handful

3,647 views
Skip to first unread message

meher...@gmail.com

unread,
Sep 28, 2016, 8:52:08 PM9/28/16
to Prometheus Developers
Is it possible to drop all metrics from a scrape and keep only a handful

- job_name: 'statsd'
scrape_interval: 10s
scrape_timeout: 10s
honor_labels: true
static_configs:
- targets: ['x.y.z.w:9102']
metric_relabel_configs:
- source_labels: [ __name__ ]
regex: '^consul_.*' ---- drop all metrics that begin with consul_
action: drop
- source_labels: [ __name__ ]
regex: '.*_dns_domain_query_.*' ---- except keep metric consul_dns_domain_query_.*
action: keep

Brian Brazil

unread,
Sep 29, 2016, 2:10:53 AM9/29/16
to Meher Garda, Prometheus Developers
On 29 September 2016 at 01:52, <meher...@gmail.com> wrote:
Is it possible to drop all metrics from a scrape and keep only a handful

Yes, though be aware that relabel configs execute in order and drop/keep halt processing if they do/don't match so you probably want those two the other way around.

Why do you have consul metrics coming via statsd rather than via the consul_exporter?

Brian
 

- job_name: 'statsd'
    scrape_interval: 10s
    scrape_timeout:  10s
    honor_labels: true
    static_configs:
      - targets: ['x.y.z.w:9102']
    metric_relabel_configs:
      - source_labels: [ __name__ ]
        regex: '^consul_.*'                     ----  drop all metrics that begin with consul_
        action: drop
      - source_labels: [ __name__ ]
        regex: '.*_dns_domain_query_.*'  ---- except keep metric consul_dns_domain_query_.*
        action: keep

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Ben Kochie

unread,
Sep 29, 2016, 3:45:51 AM9/29/16
to Brian Brazil, Meher Garda, Prometheus Developers
It's pretty common for us to have duplicate metrics coming from ganglia -> statsd -> statsd_exporter.  This is how we ingest data into Prometheus until we get a proper exporter. setup.  But in order to avoid breaking existing graphs in Graphite, we lave things around but drop them from Prometheus ingestion.

It's a great statsd+Graphite to Prometheus transition technique.

On Thu, Sep 29, 2016 at 8:10 AM, Brian Brazil <brian....@robustperception.io> wrote:
On 29 September 2016 at 01:52, <meher...@gmail.com> wrote:
Is it possible to drop all metrics from a scrape and keep only a handful

Yes, though be aware that relabel configs execute in order and drop/keep halt processing if they do/don't match so you probably want those two the other way around.

Why do you have consul metrics coming via statsd rather than via the consul_exporter?

Brian

- job_name: 'statsd'
    scrape_interval: 10s
    scrape_timeout:  10s
    honor_labels: true
    static_configs:
      - targets: ['x.y.z.w:9102']
    metric_relabel_configs:
      - source_labels: [ __name__ ]
        regex: '^consul_.*'                     ----  drop all metrics that begin with consul_
        action: drop
      - source_labels: [ __name__ ]
        regex: '.*_dns_domain_query_.*'  ---- except keep metric consul_dns_domain_query_.*
        action: keep

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

meher...@gmail.com

unread,
Sep 29, 2016, 12:26:17 PM9/29/16
to Prometheus Developers, meher...@gmail.com
On Wednesday, September 28, 2016 at 11:10:53 PM UTC-7, Brian Brazil wrote:
> On 29 September 2016 at 01:52, <meher...@gmail.com> wrote:
> Is it possible to drop all metrics from a scrape and keep only a handful
>
>
>
> Yes, though be aware that relabel configs execute in order and drop/keep halt processing if they do/don't match so you probably want those two the other way around.
>
>
> Why do you have consul metrics coming via statsd rather than via the consul_exporter?
>
>
> Brian
>  
>
>
> - job_name: 'statsd'
>
>     scrape_interval: 10s
>
>     scrape_timeout:  10s
>
>     honor_labels: true
>
>     static_configs:
>
>       - targets: ['x.y.z.w:9102']
>
>     metric_relabel_configs:
>
>       - source_labels: [ __name__ ]
>
>         regex: '^consul_.*'                     ----  drop all metrics that begin with consul_
>
>         action: drop
>
>       - source_labels: [ __name__ ]
>
>         regex: '.*_dns_domain_query_.*'  ---- except keep metric consul_dns_domain_query_.*
>
>         action: keep
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>
> --
>
>
> Brian Brazil
> www.robustperception.io

Hi brian

I am using consul_exporter but the consul exporter does not give metrics from serf and raft like say consul.consul.leader.reconcile.count hence the need to use statsd_exporter

if you know of more prometheus native way to get serf and raft metircs from consul let me know

ne...@rafay.co

unread,
Apr 5, 2018, 1:49:04 AM4/5/18
to Prometheus Developers

Hey guys,
I am trying to drop all metrics and only keep ALERTS. Do you guys see anything wrong in config below?

write_relabel_configs:
- source_labels: [__name__]
separator: ;
regex: .*ALERTS.*
replacement: $1
action: keep
- source_labels: [__name__]
separator: ;
regex: (.*)
replacement: $1
action: drop

Thanks

Brian Brazil

unread,
Apr 5, 2018, 3:17:01 AM4/5/18
to ne...@rafay.co, Prometheus Developers
This action drops everything. You want to remove it.

Brian
 

Thanks

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/b0d0f416-afc6-4c08-bdbb-2063527a6c78%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Nehal Syed

unread,
Apr 5, 2018, 2:56:55 PM4/5/18
to Brian Brazil, Prometheus Developers
Thanks Brian, tick worked!!!

Nehal
Reply all
Reply to author
Forward
0 new messages