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.

Un-incremented counters don't have value 0

See original GitHub issue

When I navigate to my metrics endpoint, some counters don’t have values because they were never incremented. Such a counter is the unknown_failure_total which gets incremented on unhandled exceptions.

I have Prometheus hooked up to Grafana and it keeps alerting me that there’s missing data for some counters. I don’t want to suppress this alert because missing data could also mean that Grafana is not able to reach my Prometheus server.

The HELP and TYPE statements are printed even for un-incremented counters, but their zero value is not. Should a 0 value be printed for counters which have yet to be incremented?

# HELP postgres_upsert_failure_total postgres_upsert_failure_total
# TYPE postgres_upsert_failure_total counter
postgres_upsert_failure_total{environment="production"} 2

# HELP unknown_failure_total cli_unknown_failure_total
# TYPE unknown_failure_total counter

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
siimoncommented, Jul 6, 2017

Published in 10.0.1!

0reactions
dm3commented, Jun 29, 2017

With labels present there’s no way to know the label values to display a default zero. However, once you’ve initialized the “child” with the label values by calling the SimpleCollector#labels method, you should see zero as in the no-labels case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my counter incrementing in loop, but returns zero?
With my current project, I have to keep a counter of the number of insertions into a TreeMap<String, TreeSet<Song>> . The project is...
Read more >
Please explain why counter does not increment
"CommandOne_Counter" is declared as "int CommandOne_Counter = 0;" near the top of the code in a udata section and I would expect it...
Read more >
Solved CSE21 Lab 9: InheritanceTask 1: Counter.javaCounter
If the counter's value is 0, a call to decrement should have no effect. Otherwise, it should reduce the counter's value by 1....
Read more >
Four ways to implement a synchronized counter in Java
Let's see how we can implement a synchronized counter in Java (For simplicity, we're implementing a counter which only increments the value, but...
Read more >
Example: Counter Class
java is to have it inherit from Counter.java . It would inherit the increment and reset operations from Counter , replacing only the...
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