Stacked Bar Chart with Increase(Counter[time])

  • What Grafana version and what operating system are you using?
    Grafana 8.3.1 (I tried with 9.1.7 as well)

  • What are you trying to achieve?
    I have different Counter prometheus metrics per Objects.
    I want to create a Stacked Bar Chart over the time, an “Acitvity per Day Panel”.
    A counter is incremented each time an object is used on back end side.

My data looks like :

object_usage_count_total{object="tc 1"} 2.0
object_usage_count_total{object="tc5"} 3.0
  • How are you trying to achieve it?

I’m using this prometheus query with Min Step 5m (I’m using 5m for test purpose even if my goal is 1d)
And I’ve selected Stacked Bar Chart

  • What happened?

I have the following result at this moment :

Which is pretty nice, it looks like what I want, except that the first usage of an object is never shown.
For this example I used 3 time TC5 and 2 time TC1. And as we can see there’s a total of 2 activity for TC5 and 1 activity for TC1.

I think that I know what is the origin of this issue.
When an object is used for the first time, the created counter have the value 1 as we can see on the image below.
The value 0 never exists for this counter, so for the “increase” method the value didn’t increase by one.

I thought of initializing the counter to 0 before, but the problem is that a new object can be created at any moment, and when it’s created, it is automatically used once. The state “used 0 time” doesn’t really exist.

I have 2 questions:

Is it considered as a bug or is the behavior of “increase” like this on purpose ?

Do you have a solution that might work in my case ?


(Maybe I’m on the wrong category sorry, I didn’t found anything related to “increase”)

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?
    Yes, just saw on every “Activity per day” topics that “increase” is what I need.
    But no specific URL to provide.