For example, do notuse a counter for the number of currently running processes; instead use a gauge. Metric names. So, other than for counters, for gauges it is the current value that is of interest. INNOQ Technology Lunch: Cloud Native Coding ,To better understand the results of our upcoming queries, it’s a good idea to have a little playground where we can create and increase a counter in a simple and controlled way. This logic prevents us from losing old data, so using rate() is a good idea when you need this feature.Note: because of this automatic adjustment for resets, if you want to use any other aggregation together with rate() then you must apply rate() first, otherwise the counter resets will not be caught and you will get weird results.Either way, PromQL currently will not prevent you from using rate() with a gauge, so this is a very important thing to realize when choosing which metric should be passed to this function.
Build dashboards with the metrics exported by Nomad.cAdvisor is an open source container monitoring platform developed and maintained by Google. Knowing this will save you from headaches in the long-term. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. The reason is (again according to the.If we execute the query, we see the expected number which is approximately 0.2 orders per second (again, don’t expect exact numbers).We can even extend the query to calculate the orders per minute by just multiplying the resulting instant vector with 60 seconds.If we look at that orders/minute graph it looks like this:It looks a little strange at first glance, because the values seem to jump up and down. Here is what instant vectors would look like:As you can see, instant vectors only define the value that has been most recently scraped. Due to that, the unsteadiness of its increase, that is perfectly normal in most cases, is reflected more directly in the graph.

What’s more, the scrape interval due to added randomness might not align perfectly with the range vector, even if it is a multiple of the range vector’s time range.In such a case, rate() calculates the rate with the data that it has and then, if there is any information missing, extrapolates the beginning or the end of the selected window using either the first or last two data points.
There is no silver bullet here: at the very minimum it should be two times the scrape interval. It turned out that I had underestimated the complexity of Prometheus Counters. I assumed that those are the simplest metrics available and it should be easy to extract some meaningful numbers and graphs out of them.

It is incorrect to use rate() with gauges because the reset detection logic will mistakenly catch the values going down as a “counter reset” and you will get wrong results.All in all, let’s say you have a counter metric which is changing like this:The reset between “10” and “2” would be caught by irate().Last but not least, it’s important to understand that rate() performs extrapolation. As an easy option we can create a simple spring-boot application and use the Micrometer Prometheus plugin to write our counter. I focussed on a couple of already existing counter metrics. Also, a keen reader would have noticed that using rate() is a hack to work around the limitation that floating-point numbers are used for metrics’ values and that they cannot go up indefinitely so they are “rolled over” once a limit is reached. So, you could write an alert like this:This would inform you if any of the backends have an increased amount of connection errors.