This works for me:

sum(increase(http_request_duration_seconds_count{ecs_cluster=~"$ecs_cluster", instance_id=~"$instance_id"}[$__range]))

Activated instant query and set calculation to last not null

Here is the pane JSON:

{
  "cacheTimeout": null,
  "datasource": "Prometheus",
  "description": "",
  "fieldConfig": {
    "defaults": {
      "custom": {},
      "unit": " requests",
      "decimals": 0,
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "blue",
            "value": null
          }
        ]
      },
      "mappings": [],
      "nullValueMode": "connected"
    },
    "overrides": []
  },
  "gridPos": {
    "h": 2,
    "w": 5,
    "x": 0,
    "y": 4
  },
  "id": 4,
  "interval": null,
  "links": [],
  "maxDataPoints": 100,
  "options": {
    "reduceOptions": {
      "values": false,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "horizontal",
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "none",
    "justifyMode": "auto",
    "fieldOptions": {
      "calcs": [
        "lastNotNull"
      ]
    }
  },
  "pluginVersion": "7.1.0",
  "targets": [
    {
      "expr": "sum(increase(http_request_duration_seconds_count{ecs_cluster=~\"$ecs_cluster\", instance_id=~\"$instance_id\"}[$__range]))",
      "hide": false,
      "instant": true,
      "interval": "",
      "intervalFactor": 1,
      "legendFormat": "",
      "refId": "A"
    }
  ],
  "timeFrom": null,
  "timeShift": null,
  "title": "",
  "type": "stat"
}

Answer from trallnag on Stack Overflow
🌐
Grafana
grafana.com › docs › k6 › latest › javascript-api › k6-metrics › counter
Counter | Grafana k6 documentation
For the complete documentation index, use https://grafana.com/llms-full.txt. ... Counter is an object for representing a custom cumulative counter metric.
🌐
Grafana
community.grafana.com › time series panel
SOLVED Display Counter Increase in Grafana - Time Series Panel - Grafana Labs Community Forums
June 26, 2023 - I had this problem where in grafana I wanted to show the increase of a gauge or counter over time. I didn’t want to show the absolute value, but the increase. (I wanted to embed more pictures, but couldn’t because I can…
Discussions

time series - Grafana Prometheus Counter - Stack Overflow
I have trying to get exact count for an event in a Grafana visualization using Prometheus as timeseries DB. But the counter is showing incorrect records. I am getting a higher count for 2 days that... More on stackoverflow.com
🌐 stackoverflow.com
Aggregating counters over time
0 I have a counter of events, and trying to plot aggregate counts per day, per hour etc., but having trouble making sense of the results I am getting. Here, I plotted two queries: sum(increase(counter[1h])) with Min St… More on community.grafana.com
🌐 community.grafana.com
0
0
February 22, 2023
How to create graph of counter-changes
The prometheus graph shows totals as expected. I want to show in Grafana, graph (line - time series) when counter was updated, the value and the time of update. x - time y - counter value something like this (48,22,7,199,500) I tried functions rate,delta. Got strange results, even tried with ... More on community.grafana.com
🌐 community.grafana.com
0
0
September 11, 2023
Properly plot counters with Prometheus in Grafana
Hi, I have been trying to figure out how to properly plot some of the following counters to show some breakdown on workflow_type or activity_type: temporal_workflow_completed_total temporal_workflow_failed_total temporal_request_total (for plotting all successful activity) temporal_activit... More on community.temporal.io
🌐 community.temporal.io
4
0
March 1, 2023
🌐
Last9
last9.io › blog › grafana-rate-function
Why Grafana's Rate Function Is Your Dashboard's Best Kept Secret | Last9
April 25, 2025 - In technical terms, the rate function takes a counter metric and converts it to a per-second rate of change. This transformation is essential for properly analyzing metrics like: ... Without the rate function, counter metrics would just keep climbing upward, making it nearly impossible to spot performance issues or unusual patterns. ... If you’re setting up Grafana with Prometheus, this guide on getting them to work together covers the essentials.
🌐
Google Groups
groups.google.com › g › prometheus-users › c › 5Z5q2pi3WeU
Prometheus / Grafana - How to best display counters in a Singlestat panel?
Let Grafana handle the "increase" calculation by using "Stat: delta" under the Options -> Value tab. So far, we've had more confidence in this approach as the results have been accurate. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... Be careful with sum(something_total) – this is only valid if all instances reset their counters (restart) at the same time.
Top answer
1 of 2
10

This works for me:

sum(increase(http_request_duration_seconds_count{ecs_cluster=~"$ecs_cluster", instance_id=~"$instance_id"}[$__range]))

Activated instant query and set calculation to last not null

Here is the pane JSON:

{
  "cacheTimeout": null,
  "datasource": "Prometheus",
  "description": "",
  "fieldConfig": {
    "defaults": {
      "custom": {},
      "unit": " requests",
      "decimals": 0,
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "blue",
            "value": null
          }
        ]
      },
      "mappings": [],
      "nullValueMode": "connected"
    },
    "overrides": []
  },
  "gridPos": {
    "h": 2,
    "w": 5,
    "x": 0,
    "y": 4
  },
  "id": 4,
  "interval": null,
  "links": [],
  "maxDataPoints": 100,
  "options": {
    "reduceOptions": {
      "values": false,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "horizontal",
    "textMode": "auto",
    "colorMode": "value",
    "graphMode": "none",
    "justifyMode": "auto",
    "fieldOptions": {
      "calcs": [
        "lastNotNull"
      ]
    }
  },
  "pluginVersion": "7.1.0",
  "targets": [
    {
      "expr": "sum(increase(http_request_duration_seconds_count{ecs_cluster=~\"$ecs_cluster\", instance_id=~\"$instance_id\"}[$__range]))",
      "hide": false,
      "instant": true,
      "interval": "",
      "intervalFactor": 1,
      "legendFormat": "",
      "refId": "A"
    }
  ],
  "timeFrom": null,
  "timeShift": null,
  "title": "",
  "type": "stat"
}

2 of 2
0

Prometheus may return inaccurate results from increase() function because of the chosen data model - see this issue for details.

If you need accurate results, then the following options exist:

  • To use offset. Try something like the following: sum(http_server_requests_seconds_count - http_server_requests_seconds_count offset $__range). Note that this approach works only if the given metric - http_server_requests_seconds_count wasn't reset to 0 (aka counter reset) on the given time range.
  • To use increase() function from MetricsQL. It returns accurate values - see these docs for details.
🌐
Grafana
community.grafana.com › t › aggregating-counters-over-time › 82352
Aggregating counters over time - Grafana - Grafana Labs Community Forums
February 22, 2023 - 0 I have a counter of events, and trying to plot aggregate counts per day, per hour etc., but having trouble making sense of the results I am getting. Here, I plotted two queries: sum(increase(counter[1h])) with Min Step being 1 hour (green bars) and sum(increase(counter[1d])) with Min Stem 1 day (orange bars) Looking at the rightmost organge bar here, I expect the value (69055) to be the sum of the 24 green bars to the left of it.
🌐
Grafana
community.grafana.com › time series panel
How to create graph of counter-changes - Time Series Panel - Grafana Labs Community Forums
September 11, 2023 - I have a Counter Metric in Prometheus, “total_calls”. This counter was appended 5 times: 48,22,7,199,500. The prometheus graph shows totals as expected. I want to show in Grafana, graph (line - time series) when c…
🌐
Temporal
community.temporal.io › community support
Properly plot counters with Prometheus in Grafana - Community Support - Temporal Community Forum
March 1, 2023 - Hi, I have been trying to figure out how to properly plot some of the following counters to show some breakdown on workflow_type or activity_type: temporal_workflow_completed_total temporal_workflow_failed_total temporal_request_total (for plotting all successful activity) temporal_activit...
Find elsewhere
🌐
Grafana
community.grafana.com › time series panel
Monitor that Counter increases by exactly 1 for a given time period - Time Series Panel - Grafana Labs Community Forums
January 18, 2022 - Hi everyone! I have an application that provides me with Prometheus metrics that I use Grafana to monitor. One of these metrics is a Prometheus Counter() that increases with 1 every day somewhere between 4PM and 6PM. I…
🌐
Reddit
reddit.com › r/grafana › suggestions to visualize a lot of counters
r/grafana on Reddit: Suggestions to visualize a lot of counters
March 7, 2022 -

Hi everyone!

I'm kind of a newbie when it comes to Grafana, so I may have overlooked something easy.

I have been asked to make a dashboard displaying a large number of counters (>500). The values of the counters come from sensors that are physically ordered in a certain way (let's say Counter0 to Counter500 from left to right), so it's important to keep them displayed in the same order.

While the user would like to be able to know the precise value of each counter, what matters the most to them is to have a quick overview of the distribution of those values, for example to immediately see that counters on the left have significantly lower values than counters on the right.

My first instinct was to use a Bar Gauge panel but it becomes a mess when there are too many values to display.

User would be happy with the ability to "zoom in and out" of the panel, for example to have a quick overview to see whether the values are more or less equally distributed and then "zoom in" to see which precise counter is different, but I don't see how to do that with Grafana.

Does anyone have any suggestion?

🌐
Reddit
reddit.com › r/prometheusmonitoring › need help visualizing a simple counter
r/PrometheusMonitoring on Reddit: Need help visualizing a simple counter
December 11, 2024 -

Hi Prometheus community,

I’m relatively new to Prometheus, having previously used InfluxDB for metrics. I’m struggling to visualize a simple counter (http_requests_total) in Grafana, and I need some advice. Here’s what I’m trying to achieve:

  1. Count graph, NOT rate or percentage: I want the graph to show the number of requests over time. For example, if I select “Last 6 hours,” I want to see how many requests occurred during that time window.

  2. Relative values only: I don’t care about the absolute counter value (e.g., "150,000" at some point). Instead, I want the graph to start at 0 for the beginning of the selected time window and show relative increments from there.

  3. Smooth increments: I don’t want to see sharp peaks every time the counter increments, like what happens with increase().

  4. Adaptable to any time frame: The visualization should automatically adjust for any selected time range in Grafana.

Here’s an example of what I had with InfluxDB (attached image). It shows the actual peaks and their sizes in absolute numbers over time, which is exactly what I need.

I can’t seem to replicate this with Prometheus. Am I missing something fundamental?

Thanks for your help!

🌐
Grafana
grafana.com › docs › k6 › latest › javascript-api › k6-metrics › counter › counter-add
Counter.add(value, [tags]) | Grafana k6 documentation
For the complete documentation index, use https://grafana.com/llms-full.txt. ... Add a value to the Counter metric.
🌐
Reddit
reddit.com › r/prometheusmonitoring › counter in grafana when pod restart with increase function
r/PrometheusMonitoring on Reddit: Counter in Grafana when pod restart with increase function
April 3, 2025 -

Hello everyone !

I have a service which expose a counter. That counter is inc of 1 every 10s for example. I would like to display that total value in grafana like this, with increase function. Grafana says that increase function manage pod restart.

Problem came when my service restart for any reason, my counter go back to 0. But i would like in grafana that my new counter start to the last value (lets say here 22) and not from 0.

First screenshot use increase with $__range of 3hours, which seem to working nicely. But when i change timerange from 3h to 1h for example, when i have a restart i have that dashboard

I don't have my linear function that i would, i don't know why my curve is straight and do not increase. If i take more range, sometime that work, sometime i got decrease, which should never happen with a counter...

Thanks for your help :)

🌐
Grafana
community.grafana.com › time series panel
How to add counter values for counter resets - Time Series Panel - Grafana Labs Community Forums
November 5, 2025 - I have a counter which has reset twice. The value has changed from a start of 482 and the counter has reset and stuck at 144. I want to calculate the total counter value 432 + 144 = 576. I’ve used the sum by name (increase functionName[range which is present for those values]) it gives me ...
🌐
Grafana
community.grafana.com › prometheus
Displaying counter metrics - Prometheus - Grafana Labs Community Forums
January 10, 2020 - Hi, I need help dealing with ‘counter’ metrics. Basically I am querying network interface stats. As part of this I have metrics ‘BytesIn’ and ‘BytesOut’. Both of them are counters, and doesnt represent the bandwidth, wh…
Top answer
1 of 2
9

That's a correct way to do it. You can also use increase() which is syntactic sugar for using rate() that way.

Can someone explain how the range selector

This is only used by Prometheus, and indicates what data to work over.

the Step and Resolution settings in grafana influence each other?

This is used on the Grafana side, it affects how many time slices it'll request from Prometheus.

These settings do not directly influence each other. However the resolution should work out to be smaller than the range, or you'll be undersampling and miss information.

2 of 2
0

The 3600 * sum(rate(signup_total[1h])) can be substituted with sum(increase(signup_total[1h])) . The increase(counter[d]) function returns counter increase on the given lookbehind window d. E.g. increase(signup_total[1h]) returns the number of signups during the last hour.

Note that the returned value from increase(signup_total[1h]) may be fractional even if signup_total contains only integer values. This is because of extrapolation - see this issue for technical details. There are the following solutions for this issue:

  • To use offset modifier: signup_total - (signup_total offset 1h) . This query returns correct results if signup_total wasn't reset to zero during the last hour. In this case the sum(signup_total - (signup_total offset 1h)) is roughly equivalent to sum(increase(signup_total[1h])), but returns more accurate integer results.
  • To use VictoriaMetrics. It returns the expected integer results from increase() out of the box. See this article and this comment for technical details.
🌐
Grafana
community.grafana.com › t › correct-representation-of-counter-metrics › 105654
Correct representation of counter metrics - Grafana - Grafana Labs Community Forums
October 16, 2023 - Hello, I wanted to understand the correct representation of counter metrics prometheus. I have one counter metrics coming from prometheus data source and I need help in its correct representation on time-series graph. I am fetching some value and as per graph, there was a positive value “1” ...
🌐
Grafana
community.grafana.com › t › how-to-count-the-number-of-events-in-the-selected-time-range › 54603
How to count the number of events in the selected time range - Grafana / Prometheus - Grafana Labs Community Forums
October 12, 2021 - When the selected timerange covers the startup phase of a process, the first N log level samples are null before the counter delivers the count of the first log entries (see screenshot). In this case Grafana’s range transformation ignores the null values so that a wrong range value is computed.
🌐
Grafana
community.grafana.com › time series panel
Time Series of counter rates from Prometheus: organize as (a, b) with an additional label z - Time Series Panel - Grafana Labs Community Forums
November 26, 2024 - Using Grafana 11.2.0 Prometheus metrics are counter(s) with labels “a”, “b”, and “z”. “a” and “b” labels separate counter metrics, but label “z” is solely a useful annotation. I would like to (1) colorize the specific s…
🌐
Grokipedia
grokipedia.com › troubleshooting prometheus counters in grafana
Troubleshooting Prometheus Counters in Grafana — Grokipedia
January 14, 2026 - Prometheus counters are a fundamental ... Prometheus data sources, these counters are often displayed in Stat panels to provide at-a-glance summaries of key performance indicators.[3][4] Troubleshooting Prometheus...