Suggest add prefix setting for <scrape_config> in prometheus.yml

1,313 views
Skip to first unread message

keh...@gmail.com

unread,
Aug 13, 2017, 4:32:02 PM8/13/17
to Prometheus Developers
Hi,
Is it possible for Prometheus to support a [prefix:<string>] filed in <scrape_config>.
So that the names of the metrics collected from this scrape job will have a prefix. I got the idea from the netdata prometheus API, where you can set prefix=netdata_ in url params and then you got data looks like
netdata_aa_aa
netdata_aa_bb

I think this is very useful for in some cases, you don't know what you've collected from the job. And currently prometheu don't support query metrics names by labels. You may ofthen got very greedy metric name like "jvm_memory_...". Only when you query it then you can tell it may just be jvm info of a small application.

Ben Kochie

unread,
Aug 14, 2017, 3:49:04 AM8/14/17
to keh...@gmail.com, Prometheus Developers
This can be done with metric_relabel_configs.

Add this to the job:

metric_relabel_configs:
  - source_labels: [__name__]

    target_label: __name__
    replacement: "prefix_${1}"



--
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/84f1c5ea-2241-4bc1-b020-3c961e9ef0b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Brazil

unread,
Aug 14, 2017, 4:20:48 AM8/14/17
to Ben Kochie, 柯豪, Prometheus Developers
On 14 August 2017 at 08:49, Ben Kochie <sup...@gmail.com> wrote:
This can be done with metric_relabel_configs.

This incidentally is not recommend, this is what labels are for. 

> You may ofthen got very greedy metric name like "jvm_memory_...". Only when you query it then you can tell it may just be jvm info of a small application.

You would have specified which application you're getting the metrics from with the job label here.

Brian
 

Add this to the job:

metric_relabel_configs:
  - source_labels: [__name__]

    target_label: __name__
    replacement: "prefix_${1}"
On Sun, Aug 13, 2017 at 10:32 PM, <keh...@gmail.com> wrote:
Hi,
Is it possible for Prometheus to support a [prefix:<string>] filed in <scrape_config>.
So that the names of the metrics collected from this scrape job will have a prefix. I got the idea from the netdata prometheus API, where you can set prefix=netdata_ in url params and then you got data looks like
netdata_aa_aa
netdata_aa_bb

I think this is very useful for in some cases, you don't know what you've collected from the job. And currently prometheu don't support query metrics names by labels. You may ofthen got very greedy metric name like "jvm_memory_...". Only when you query it then you can tell it may just be jvm info of a small application.


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

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

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



--
Reply all
Reply to author
Forward
0 new messages