On 27.10.20 07:58, [email protected] wrote:
>
> I have metrics for http request count . I want to display the number of
> success
> counts by each day .
>
> http_request{probe="success"} 3500
>
> I want to find the http_request sum grouped by day . eg.
>
> Oct 27 : 300
> Oct 26 : 350
> Oct 25 : 325
> Oct 24 : 375 .. etc
>
> Is it possible to group this way on day basis using promql .
The PromQL query for "how many HTTP requests over the last day" would
look like this:
increase(http_request{probe="success"}[1d])
However, that's not for the last calendar day, but just for the last
24 hours back from the evaluation time.
The Prometheus UI (or similar things in Grafana etc.) allow you to set
the evaluation time to midnight of a specific day. Then you get your
result for the calendar day preceding that timestamp.
>From within PromQL, you cannot (yet) set a fixed evaluation time. But
you could craft a call to the Prometheus HTTP API and use it with
`curl`. The `query_range` endpoint will allow you to get those
values. See
https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries
in the docs.
In your case, you'll probably end up with something like:
curl
'http://localhost:9090/api/v1/query_range?query=increase%28http_request%7Bprobe%3D%22success%22%7D%5B1d%5D%29&start=2020-10-25T00:00:00Z&end=2020-10-28T00:00:00Z&step=86400s'
--
Björn Rabenstein
[PGP-ID] 0x851C3DA17D748D03
[email] [email protected]
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/20201103222058.GW3373%40jahnn.