Scrape more than one value at once, per second?

34 views
Skip to first unread message

b0nes

unread,
Jun 3, 2020, 2:01:45 PM6/3/20
to Prometheus Users
Hello,

I was wondering if the following is possible:
  • Have a Python or Bash script check duration of a certain API call 5-10 times per second
  • Scrape these stats once per second
  • Calculate min, avg, 0.5, 0.9, 0.99 quantiles, max and graph them in Grafana.
I spent many hours today trying to figure this out, and along the way I used the pushgateway and statsd exporter.
Pushgateway seems to override the last value until it gets scraped, which isn't what I want - I want all values, not just the latest one.
statsd has a summary option, but doesn't provide a min and max value.

Anyone know how to do what I want?

Ben Kochie

unread,
Jun 3, 2020, 2:10:59 PM6/3/20
to b0nes, Prometheus Users
You're probably looking for the histogram data type. It allows you to calculate quantiles over time without having to collect every sample.

--
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/2366deaa-7db7-4ee6-a73e-bb4d30c5d6ff%40googlegroups.com.

b0nes

unread,
Jun 3, 2020, 2:46:17 PM6/3/20
to Prometheus Users

I've looked into it... I want to store the values though, and the histogram just keeps a count of how many are faster than a certain threshold.
It also calculates a quantile over the amount of values in these buckets, which is just an approximation and not an actual quantile based on the values.
In short, it doesn't seem that's what I need, as I also cannot figure out an accurate minimum and a maximum value.


Op woensdag 3 juni 2020 20:10:59 UTC+2 schreef Ben Kochie:
You're probably looking for the histogram data type. It allows you to calculate quantiles over time without having to collect every sample.

On Wed, Jun 3, 2020, 20:01 b0nes <h.b...@gmail.com> wrote:
Hello,

I was wondering if the following is possible:
  • Have a Python or Bash script check duration of a certain API call 5-10 times per second
  • Scrape these stats once per second
  • Calculate min, avg, 0.5, 0.9, 0.99 quantiles, max and graph them in Grafana.
I spent many hours today trying to figure this out, and along the way I used the pushgateway and statsd exporter.
Pushgateway seems to override the last value until it gets scraped, which isn't what I want - I want all values, not just the latest one.
statsd has a summary option, but doesn't provide a min and max value.

Anyone know how to do what I want?

--
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 promethe...@googlegroups.com.

Ben Kochie

unread,
Jun 3, 2020, 3:35:13 PM6/3/20
to b0nes, Prometheus Users
This is not a use case for Prometheus. Prometheus is a metrics system, not an event system.

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/a4b4bc75-09f9-4302-b435-cf988f092885%40googlegroups.com.

Herman Bonnes

unread,
Jun 3, 2020, 3:59:53 PM6/3/20
to Ben Kochie, Prometheus Users
Ah, I see you are right.
It seems the blackbox exporter, and either summary or histograms (with statsd exporter) are then my best bets.
Thanks for the info.

Op wo 3 jun. 2020 om 21:35 schreef Ben Kochie <sup...@gmail.com>:

Cameron Kerr

unread,
Jun 5, 2020, 6:26:26 AM6/5/20
to Prometheus Users
If you implement the API yourself it would be better to instrument that; that way you have real tests based on how clients are actually using the API and not synthetic tests based on someones belief in how the API will be used.

Or if you're logging this activity (eg. to Elasticsearch or some other event database), then you could write some python (or other) program that uses prometheus_client library to query the logs and emit suitable metrics (either as an http server, or to a push gateway, or to a file for a textfile collector).

Cheers,
Cameron
Reply all
Reply to author
Forward
0 new messages