0

I have configured a custom prometheus mertic named "my_metrics" in my code which is simply capturing a special failure condition of my API.

After deployment, if I want to check what the increment value on that counter in last 1 hour, I am writing promQ sum(increase(my_metrics(...)[30m])) but I am always getting 0 as response even when I am sure that that error condition has met 2 times in last 30 min and I am getting that confirmation in logs.

Based on some online search, I got some blogs where they say some issue with increase() function. Can someone tell what exactly is that issue, or how can I get my data using some other promQL. Basically I want to get the increment in my counter's value in last 30 mins.

  • Is your metric really a counter? Also, are you sure prometheus has information on this metic changes (have you checked graph produced by simple query `my_metric`)? – markalex Aug 10 '23 at 08:00
  • Do you really think it's adequate request "I got some blogs where they say some issue with increase() function. Can someone tell what exactly is that issue"? How should we know what blog with what issue you have read? – markalex Aug 10 '23 at 08:02

1 Answers1

0

You need to use the following query for calculating the summary increase of all the time series with the my_metrics name over the last 30 minutes:

sum(increase(my_metrics{...}[30m]))

Note that time series filters must be put inside curly braces - {...}.

Note also that Prometheus can return unexpected results from increase() function applied to slow-changing integer counter. See this answer for details.

valyala
  • 11,669
  • 1
  • 59
  • 62