-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add $perSecond macro for computing rate for counter-type metrics #78
Comments
Hi @JiriHorky I don't understand I have some test data in table
The $timeSeries query:
The result shows how many events were collected per minute. To calculate per-second we need to divide result as following:
Let's apply
We see the same result (except of first point because runningDifference comparing first point with 0). The expression |
Hi @hagen1778 , thanks for reaching back. For the input that you described, the $rate macro works well. But for "counter" metrics, i.e. metrics that only grow, your input would look like this:
And for this input, you need to "derive" even the value, not just the time. Please note that this is very standard way of collecting metrics - it is called Counter in collectd, and your "bytes transferred" from "ifconfig" output are collected like that. |
Hi @JiriHorky , Sorry for delay! Now I see the issue. The macros should get the max value from every period, substract the value from previous period and divide by the number of seconds in the period.
Then
Is the output correct? |
Hi, yes, that's exactly what I was looking for. 👍 Now, the interesting incarnation of this enhancement is #80 - I would like to see what's the solution for that :) |
First of all, thanks for the great grafana plugin.
What we are missing in our environment is a $perSecond macro that would be very similar to existing $rate macro, but would compute runningDifference of value as well
$rate is now defined as
SELECT t, v/runningDifference(t/1000) vRate FROM
$perSecond should be defined as:
SELECT t, runningDifference(v)/runningDifference(t/1000) vRate FROM
One of the usecase is to see per second network traffic throughput in bytes/s taken from ifconfig (actually collected as a counter type metric by collectd).
Basically, $rate is now usefull for Gauge type metrics, whereas $perSecond would be useful for Counter metrics.
The text was updated successfully, but these errors were encountered: