Things I tried, but not working:
delta(orders_created_count_total[1h])
sum(increase(orders_created_count_total[1h]))
max_over_time(orders_created_count_total[1h]) - min_over_time(orders_created_count_total[1h])
I’m having the same issue. sum(increase(orders_created_count_total[1h])) is also the function that I’m using, but it either returns 0 or a very low number.
Say my counter has had gone from 1000 to 1600 in one hour, I expect the above to returns 600, but get ~5.
The counter is created by the following Golang code:
prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "",
Name: "state_total",
Help: "Count of state transitions",
ConstLabels: labels,
}, []string{"from", "to", "userId"})
And increments are done using m.stateCount.WithLabelValues(string(from), string(to), userId).Inc()
The attached photo has sum(increase(...[24h])) and sum(...), where the number shown is Last* and the duration of the graph is 24 hours. It is clear, that the total changes in the right column is a lot higher than 13.1.
@Jgfrausing and @prabhu I believe to achieve what you want that query will work if you add Min step 3600
And with Min step at 3600 you do not need sum both sum(increase(orders_created_count_total[1h])) and increase(orders_created_count_total[1h]) give the same result.
@prabhu
I found the issue.
Apparently, the user id breaks the aggregation. I removed it from the metric, and everything works fine now… I think, you should look for labels with many distinct values and remove those labels.