Scraping Metrics from Endpoint

340 views
Skip to first unread message

dianad...@gmail.com

unread,
Sep 19, 2017, 5:12:40 AM9/19/17
to Prometheus Users
I have written my own exporter as an endpoint that exposes some metrics which was added as a Prometheus' target in config (and if i check the /targets the state is UP)
The exporter will show the following metrics (some http requests with the final value representing the time it took to ocmplete)

# HELP http_requests A summary of all the requests being made
# TYPE http_requests summary
http_request
{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1483 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 985 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1015 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 978

Now if I run
scrape_samples_scraped{job="testing-prometheus"}
it shows the number of metrics scrapes as being 20, 40 and going up (since the scrape_interval is 5s) so I supposed everything was fine.

But if I run
{job="ltesting-prometheus",requestPath=~"/.*"}
it only shows
  • http_request{instance="localhost:5000",job="testing-prometheus",requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"}

as a linear graph.
What I would like is to have a time series of how much the request took to run.
Any tip on how I might be able to achieve this or what I am doing wrong?

Brian Brazil

unread,
Sep 19, 2017, 5:17:35 AM9/19/17
to dianad...@gmail.com, Prometheus Users
On 19 September 2017 at 10:12, <dianad...@gmail.com> wrote:
I have written my own exporter as an endpoint that exposes some metrics which was added as a Prometheus' target in config (and if i check the /targets the state is UP)
The exporter will show the following metrics (some http requests with the final value representing the time it took to ocmplete)

# HELP http_requests A summary of all the requests being made
# TYPE http_requests summary
http_request
{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1483 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 985 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1015 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 978

Which client library are you using? There shouldn't be duplicates like this.

Brian
 
Now if I run 
scrape_samples_scraped{job="testing-prometheus"}
it shows the number of metrics scrapes as being 20, 40 and going up (since the scrape_interval is 5s) so I supposed everything was fine.

But if I run
{job="ltesting-prometheus",requestPath=~"/.*"}
it only shows
  • http_request{instance="localhost:5000",job="testing-prometheus",requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"}

as a linear graph.
What I would like is to have a time series of how much the request took to run.
Any tip on how I might be able to achieve this or what I am doing wrong?

--
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/7ffe384c-9fd1-4154-9b13-37a02a5750a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

dianad...@gmail.com

unread,
Sep 19, 2017, 6:41:48 AM9/19/17
to Prometheus Users
I am not using any client library since I'm working with .NET core ...I have written my own exporter that exposes the metrics in a text format that Prometheus can scrape from (an endpoint)
But is there a problem if there are duplicates? 
And in my case are these considered duplicates? It's the same http_request metric indeed but with a different value. 
http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1483

Would it be better to do smth like this instead?
http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200",requestDuration="1483"}


On Tuesday, September 19, 2017 at 10:17:35 AM UTC+1, Brian Brazil wrote:
On 19 September 2017 at 10:12, <dianad...@gmail.com> wrote:
I have written my own exporter as an endpoint that exposes some metrics which was added as a Prometheus' target in config (and if i check the /targets the state is UP)
The exporter will show the following metrics (some http requests with the final value representing the time it took to ocmplete)

# HELP http_requests A summary of all the requests being made
# TYPE http_requests summary
http_request
{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1483 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 985 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1015 http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 978

Which client library are you using? There shouldn't be duplicates like this.

Brian
 
Now if I run 
scrape_samples_scraped{job="testing-prometheus"}
it shows the number of metrics scrapes as being 20, 40 and going up (since the scrape_interval is 5s) so I supposed everything was fine.

But if I run
{job="ltesting-prometheus",requestPath=~"/.*"}
it only shows
  • http_request{instance="localhost:5000",job="testing-prometheus",requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"}

as a linear graph.
What I would like is to have a time series of how much the request took to run.
Any tip on how I might be able to achieve this or what I am doing wrong?

--
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,
Sep 19, 2017, 6:46:46 AM9/19/17
to dianad...@gmail.com, Prometheus Users
On 19 September 2017 at 11:41, <dianad...@gmail.com> wrote:
I am not using any client library since I'm working with .NET core ...I have written my own exporter that exposes the metrics in a text format that Prometheus can scrape from (an endpoint)

There is https://github.com/andrasm/prometheus-net but I'm not sure if it supports custom collectors.
 
But is there a problem if there are duplicates? 

Yes, that's invalid output. 

And in my case are these considered duplicates? It's the same http_request metric indeed but with a different value. 
http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200"} 1483

Yes, they've the same metric name and labels.
 
Would it be better to do smth like this instead?
http_request{requestMethod="GET",requestPath="/status/detailed",requestStatusCode="200",requestDuration="1483"}

That would not be recommended. I think you're looking for an event-logging system like ELK rather than a metrics system like Prometheus.

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/00bef3a9-dee7-4de9-8d0f-2247d6457f01%40googlegroups.com.

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



--
Reply all
Reply to author
Forward
0 new messages