I have two metrics, Counters to be precise, lets say they are called
In grafana I would like to plot is the number-of-logins divided by the number of visitors (or the other way around) over time. So I tried
rate(NumberOfLogins) / rate(NumberOfVisitors)
but this results in an error
Error executing query: invalid parameter 'query': parse error at char 46: expected type range vector in call to function "rate", got instant vector
I'm not sure what all that means. Hopefully something like this is possible. Any help would be appreciated
NaN is just a number in Prometheus. Some monitoring systems use NaN as a null or missing value, however in Prometheus NaN is just another floating point value. The way Prometheus represents missing data is to have the data, uhm, missing.
The topk() function in Prometheus and Loki returns the topk per interval. This means that at time T1, the topk series returned is a different set as that on T2. As a result of this, the graph in Grafana may contain more series in total than what you would expect.
A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart. For example, you can use a counter to represent the number of requests served, tasks completed, or errors.
Long answer: Prometheus provides two functions for calculating the average: avg_over_time calculates the average over raw sample stored in the database on the lookbehind window specified in square brackets. The average is calculated independently per each matching time series.
The rate function expect a range vector, for example:
rate(NumberOfLogins[5m])
That means to calcualte the rate within the last 5 minutes at each time point. You can change the 5m
to other time range.
Therefore this would fit you need:
rate(NumberOfLogins[5m]) / rate(NumberOfVisitors[5m])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With