On 25/04/2023 10:50, ofir y wrote:
I have a Prometheus server which scrapes data from my API metrics
endpoint that is populated using Prometheus.net library . the scraping
interval set to 15 seconds. I'm publishing a request duration summary
metric to it. this metric is published at random times to the
endpoint. but the scrape interval makes Prometheus thinks it is a new
value every 15 seconds, even if no new data was published. this causes
the _count & _sum values of the metric to be wrong, as they consider
every 15 seconds to be a new point.
my goal is to be able to count & to sum up all requests actions. so if
I had 3 requests over a period of 2 minutes like so:
00:00 request 1: duration 1 sec
00:30 request 2: duration 1 sec
01:55 request 3: duration 2 sec
the _count will be 3, and the _sum will be 4 seconds. can I achieve
this somehow by using labels or something else?
It sounds like you are trying to use Prometheus to store events, which
won't work as Prometheus is a metric system.
Normally what you would expose from your application are counters giving
the total number of the event being monitored as well as the total
duration of all of that event.
Once scraped you can then show things like the number of events over a
given period of time, as well as the average durations of those events
over that period. What you cannot do with a metric system is know
anything specific about an individual event. To do that you need an
event system, such as Loki, Elasticsearch or a SQL database.
--
Stuart Clark
--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/09688fe8-de60-88d8-3c51-ef8dbb5d87b5%40Jahingo.com.