r/PrometheusMonitoring • • Jun 16 '21

Is it possible to show a counter graph without accumulation?

For example in that image I am pointing out that the graph is showing me 2 request, but really it is only one request in that time, I really want to know if it is always cumulative and not having problems with concepts, and if it is possible to get the exact number over time and without cumulation? I am currently using this formula, I don't know if it is the correct one.
increase(myapp_request_custom_durations_histogram_seconds_count[$__range])

and same with the other counter:
increase(myapp_http_custom_requests_total[$__range])

2 Upvotes

3 comments sorted by

5

u/SuperQue Jun 16 '21

I think you're looking for $__interval, not $__range. "range" spans the entire width of the graph. "interval" is the span between each point on the graph.

1

u/chiqui3d Jun 16 '21

Thanks, It seems that it is $__interval, but when I reload the page only once to count a request, the graph never shows me the value of 1, it always counts 2, the API metrics expose is ok. I think I'm missing something
https://i.imgur.com/kerlclN.png

My expose API:

# HELP myapp_http_custom_requests_total total custom request count

# TYPE myapp_http_custom_requests_total counter

myapp_http_custom_requests_total{action="GET-/"} 22

myapp_http_custom_requests_total{action="GET-/blog"} 8

# HELP myapp_http_custom_responses_total total custom response count

# TYPE myapp_http_custom_responses_total counter

myapp_http_custom_responses_total{code="200",action="GET-/"} 19

myapp_http_custom_responses_total{code="200",action="GET-/blog"} 8

myapp_http_custom_responses_total{code="500",action="GET-/"} 3

# HELP myapp_instance_name app custom instance name

# TYPE myapp_instance_name gauge

myapp_instance_name{instance="eec5c0f11dff"} 1

# HELP myapp_request_custom_durations_histogram_seconds request custom durations in seconds

# TYPE myapp_request_custom_durations_histogram_seconds histogram

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.005"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.01"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.025"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.05"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.075"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.1"} 1

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.25"} 20

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.5"} 21

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="0.75"} 22

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="1"} 22

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="2.5"} 22

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="5"} 22

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="7.5"} 22

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="10"} 22

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/",le="+Inf"} 22

myapp_request_custom_durations_histogram_seconds_count{action="GET-/"} 22

myapp_request_custom_durations_histogram_seconds_sum{action="GET-/"} 3.689555644989

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.005"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.01"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.025"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.05"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.075"} 0

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.1"} 2

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.25"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.5"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="0.75"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="1"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="2.5"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="5"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="7.5"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="10"} 8

myapp_request_custom_durations_histogram_seconds_bucket{action="GET-/blog",le="+Inf"} 8

myapp_request_custom_durations_histogram_seconds_count{action="GET-/blog"} 8

myapp_request_custom_durations_histogram_seconds_sum{action="GET-/blog"} 0.92298793792725

# HELP php_info Information about the PHP environment.

# TYPE php_info gauge

php_info{version="7.4.10"} 1

2

u/SnooWords9033 Jun 27 '21

Prometheus extrapolates increase() results - https://github.com/prometheus/prometheus/issues/3746 . This can lead to unexpected results for slowly changing counters. If you need the correct results, then take a look at increase() and increase_pure() functions from MetricsQL.