Get Total requests in a period of time

前端 未结 7 903
予麋鹿
予麋鹿 2020-12-08 00:02

I need to show, in Grafana, a panel with the number of requests in the period of time selected in the upper right corner.

For this I need to solve 2 issues here, I w

相关标签:
7条回答
  • 2020-12-08 00:53

    Solution: In order to calculate sum of https counters on prometheus grafana you should use increase method and set generic Time Range $interval in order to sum and calculate all http requests counters.

    increase(http_requests_total[$interval])
    

    According to Prometheus Reference:

    increase() increase(v range-vector) calculates the increase in the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for. The increase is extrapolated to cover the full time range as specified in the range vector selector, so that it is possible to get a non-integer result even if a counter increases only by integer increments.

    The following example expression returns the number of HTTP requests as measured over the last 5 minutes, per time series in the range vector:

    increase(http_requests_total{job="api-server"}[5m]) increase should only be used with counters. It is syntactic sugar for rate(v) multiplied by the number of seconds under the specified time range window, and should be used primarily for human readability. Use rate in recording rules so that increases are tracked consistently on a per-second basis.

    P.S

    1. You should set the correct Quick range on Grafana for setting the right time frame you choose (that straight rendered to $interval variable) In addition I suggest to set on the Graph visualisation the right resolution and Min time interval ( in your case it's per day -> 1d)

    2.In order to sum all amount of requests just perform sum function

    sum(increase(http_requests_total[$interval]))
    
    0 讨论(0)
提交回复
热议问题