file_sd_config and metrics path relabeling

2,460 views
Skip to first unread message

Joe Garcia

unread,
Feb 20, 2018, 5:15:40 PM2/20/18
to Prometheus Users
Hi all,

We have a custom exporter that we wrote in house that queries Spectrum Performance Center.  It queries a particular element in SPC on the fly based on the metrics path it is fed and then generates the return for prometheus.  Some examples of a query:

http://spc.exporter.foo.com/int/router_number_1 - returns data collected from router_number_1

http://spc.exporter.foo.com/int/router_number_2 -  returns data collected from router_number_2


This works fine with static configs but we would like to start using file_sd_config.  From what I have read though, the metrics path is attached to the job and all we can put into the SD config file is Targets and Labels not metrics path.  In our case the target would always remain the same but the metrics path would change.  I believe the answer to this issue is to use relabel_config but I can't figure it out.  So I have a few questions:

  1. From the relabel config documentation it appears that I can change the __metrics_path__ before the scrape is made and would actually make the query against the exporter with the metrics path I want.  Is this correct?
  2. Can I put these relabel items in the SD config file?
  3. I have no idea from the relabel documentation how to set that up, can someone provide an example?

I am really confused and a good example would do wonders to help my understanding.

Thanks,

Joe

Brian Brazil

unread,
Feb 21, 2018, 3:15:22 AM2/21/18
to Joe Garcia, Prometheus Users
You can put __metrics_path__ directly in the file SD files.

Brian

 

I am really confused and a good example would do wonders to help my understanding.

Thanks,

Joe

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/ea163790-1e4d-4053-88b5-4ab4b4a7ebfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Joe Garcia

unread,
Feb 21, 2018, 10:46:04 AM2/21/18
to Prometheus Users
So that would look something like this in the SD files:

 - targets:[spc.exporter.foo.com:8001]
   labels
:
     __metrics_path__
: /int/router_number_1


Is that correct?

Since this this is under a single job, would this be scraping all targets at the same time or, as I suspect, prometheus is smart enough to randomly scrape each target within the window the time window assigned?

Joe


On Wednesday, February 21, 2018 at 3:15:22 AM UTC-5, Brian Brazil wrote:
On 20 February 2018 at 22:15, Joe Garcia <joejg...@gmail.com> wrote:
Hi all,

We have a custom exporter that we wrote in house that queries Spectrum Performance Center.  It queries a particular element in SPC on the fly based on the metrics path it is fed and then generates the return for prometheus.  Some examples of a query:

http://spc.exporter.foo.com/int/router_number_1 - returns data collected from router_number_1

http://spc.exporter.foo.com/int/router_number_2 -  returns data collected from router_number_2


This works fine with static configs but we would like to start using file_sd_config.  From what I have read though, the metrics path is attached to the job and all we can put into the SD config file is Targets and Labels not metrics path.  In our case the target would always remain the same but the metrics path would change.  I believe the answer to this issue is to use relabel_config but I can't figure it out.  So I have a few questions:

  1. From the relabel config documentation it appears that I can change the __metrics_path__ before the scrape is made and would actually make the query against the exporter with the metrics path I want.  Is this correct?
  2. Can I put these relabel items in the SD config file?
  3. I have no idea from the relabel documentation how to set that up, can someone provide an example?
You can put __metrics_path__ directly in the file SD files.

Brian

 

I am really confused and a good example would do wonders to help my understanding.

Thanks,

Joe

--
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 post to this group, send email to promethe...@googlegroups.com.



--

Brian Brazil

unread,
Feb 21, 2018, 10:51:23 AM2/21/18
to Joe Garcia, Prometheus Users
On 21 February 2018 at 15:46, Joe Garcia <joejg...@gmail.com> wrote:
So that would look something like this in the SD files:

 - targets:[spc.exporter.foo.com:8001]
   labels
:
     __metrics_path__
: /int/router_number_1


Is that correct?

That should do it.
 
Since this this is under a single job, would this be scraping all targets at the same time or, as I suspect, prometheus is smart enough to randomly scrape each target within the window the time window assigned?

Prometheus spreads scrapes across the interval.

Brian
 
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/67b8386b-5926-48d0-adee-ddaf6ae68511%40googlegroups.com.

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



--

Joe Garcia

unread,
Feb 21, 2018, 11:09:51 AM2/21/18
to Prometheus Users
Sweet thank you very much!



--
Reply all
Reply to author
Forward
0 new messages