# Query to display total number of successful request

**URL:** <https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338>\
**Category:** PromQL\
**Created:** [December 8, 2022, 12:31pm UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338 "2022-12-08T12:31:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![prometheus-dev](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@prometheus-dev](https://discuss.prometheus.io/u/prometheus-dev)\
**Post date:** [December 8, 2022, 12:31pm UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/1 "2022-12-08T12:31:17Z")

</div>

Hi,

Trying to display the total successful count for a specific endpoint in Grafana but the query below shows some metrics however when a longer date range is selected the count decreases, and I would expect the count to increase.

sum(http\_server\_requests\_seconds\_count{uri=“/api/v1/student/{studentId}”, status=“200”})

Is there any other way to display the count of total requests in Grafana?

---

<div class="post-metadata">

**Author:** ![stuart](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/stuart/32/18_2.png) [@stuart](https://discuss.prometheus.io/u/stuart)\
**Post date:** [December 8, 2022, 1:10pm UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/2 "2022-12-08T13:10:18Z")

</div>

As this looks to be a counter you should use the “increase” function.

---

<div class="post-metadata">

**Author:** ![prometheus-dev](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@prometheus-dev](https://discuss.prometheus.io/u/prometheus-dev)\
**Post date:** [December 8, 2022, 1:46pm UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/3 "2022-12-08T13:46:37Z")

</div>

Thanks. Tried replacing the sum to increase function but no data is displayed. Also is there a way to capture the count irrespective of pod restart? It seems to be when pods restarted then the counter resets to 0.

increase(http\_server\_requests\_seconds\_count{uri=“/api/v1/student/{studentId}”, status=“200”})

---

<div class="post-metadata">

**Author:** ![stuart](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/stuart/32/18_2.png) [@stuart](https://discuss.prometheus.io/u/stuart)\
**Post date:** [December 8, 2022, 2:56pm UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/4 "2022-12-08T14:56:38Z")

</div>

For a counter the absolute value has no real meaning. It is how it changes which is important. As you say it might reset to zero at any point, so you should be looking at either the increase() which tells you how much it has increased by over a period of time, or rate() which returns the rate of change (basically the increase divided by the time period).

The reason the increase didn’t work for you is because you didn’t specify the time period to calculate it over. The example in the docs ([Query functions | Prometheus](https://prometheus.io/docs/prometheus/latest/querying/functions/#increase)) uses a period of 5 minutes.

---

<div class="post-metadata">

**Author:** ![prometheus-dev](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@prometheus-dev](https://discuss.prometheus.io/u/prometheus-dev)\
**Post date:** [December 9, 2022, 6:26am UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/5 "2022-12-09T06:26:22Z")

</div>

Thank you. I tried with the time period in the increase function it works but many values are displayed eg: 0 0 3 5 .Do I need to sum up as I just need only the total count.?

---

<div class="post-metadata">

**Author:** ![stuart](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/stuart/32/18_2.png) [@stuart](https://discuss.prometheus.io/u/stuart)\
**Post date:** [December 9, 2022, 7:43am UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/6 "2022-12-09T07:43:36Z")

</div>

What time period are you using, what is the time period for your dashboard, and are you using a single stat panel or a graph?

---

<div class="post-metadata">

**Author:** ![prometheus-dev](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@prometheus-dev](https://discuss.prometheus.io/u/prometheus-dev)\
**Post date:** [December 9, 2022, 8:42am UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/7 "2022-12-09T08:42:32Z")

</div>

increase(http\_server\_requests\_seconds\_count{uri=“/api/v1/student/{studentId}”, status=“200”}[5m])

The dashboard time period selected is 15mins, 12 hours,24 hours,1 month, and so on.

When I select 1 month time period in the dashboard the count should have been increased but the count is low and 24 hours count shows more. It looks like the counter reset when the pod restarts and shows fewer numbers when I increased the period in the dashboard.

---

<div class="post-metadata">

**Author:** ![prometheus-dev](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@prometheus-dev](https://discuss.prometheus.io/u/prometheus-dev)\
**Post date:** [December 9, 2022, 8:45am UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/8 "2022-12-09T08:45:56Z")

</div>

It is a single stat panel.

---

<div class="post-metadata">

**Author:** ![stuart](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/stuart/32/18_2.png) [@stuart](https://discuss.prometheus.io/u/stuart)\
**Post date:** [December 9, 2022, 8:56am UTC](https://discuss.prometheus.io/t/query-to-display-total-number-of-successful-request/1338/9 "2022-12-09T08:56:53Z")

</div>

In which case you need to use the duration of the dashboard instead of 5m. I think Grafana has a variable called something like $\_\_interval
