question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best way to do total count in case of counter reset ?

See original GitHub issue

I am using prometheus + grafana, and wrote a simple query like sum(increase(some_count[$__range])) , although this takes the difference between the first and last values, seeing prometheus values gets restart on restart of our node server, any better approach to tackle this problem ? Sample graph explaining the drop due to server restart

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
tcurdtcommented, Apr 22, 2022

Just to leave this here:

sum by (label) (increase(metric[$__range]))

Is what I was looking for when I came here via search.

0reactions
scyantistcommented, Mar 31, 2021

@somyarocketium With prometheus + grafana I believe you can get the grand total of all increase in the current window by using the legend. You can do something like this Query: Screen Shot 2021-03-31 at 1 50 13 PM Setting $__interval will automatically use the minimum x-axis time unit based on your window resolution. $__interval is an auto scaling feature you can use with prometheus + grafana. Make sure to also set min step to 1m.

Visualization > Legend Screen Shot 2021-03-31 at 1 50 26 PM The total that is reflected in the legend will be the total increase that happened in your window. This should work regardless if a counter reset happened

Result: Screen Shot 2021-03-31 at 1 54 15 PM

Read more comments on GitHub >

github_iconTop Results From Across the Web

counter-reset - CSS: Cascading Style Sheets - MDN Web Docs
The counter-reset CSS property resets a CSS counter to a given value. This property will create a new counter or reversed counter with...
Read more >
Prometheus how to handle counters on server - Stack Overflow
Counters are allowed to be reset to 0, so there's no need to do anything special here to handle it.
Read more >
Working With Prometheus Counter Metrics - Level Up Coding
In this article, we will look at the Prometheus counter metric and explain how to use rate, increase, irate, and resets to get...
Read more >
Reset Counter - The Art of PostgreSQL
All we have to do now is sum this computed columns entries. Remember that the sum() aggregate function will simply discard nulls, so...
Read more >
resetting a counter for each day - Splunk Community
I try to count the maximum of concurrent sessions on a system where the ... to do that (or solve the problem somehow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found