Since it's a gauge (and at least theoretically line counts can decrease,
not only increase), you'll want either the delta() (
https://prometheus.io/docs/prometheus/2.18/querying/functions/#delta) or
the deriv() (
https://prometheus.io/docs/prometheus/2.18/querying/functions/#deriv)
function, multiplied by 60 (to get from per-second to per-minute).
Note that both functions can give you non-integer results even if the line
numbers only change by integer increments/decrements, as delta()
extrapolates the observed slope to the edges of the provided time window,
and deriv() does a linear regression to estimate how fast a gauge is going
up or down.
Another thing you could do (if you care about integer results) is:
my_lines_total - my_lines_total offset 1m
...to give you the absolute difference between the last sample value seen
1m ago and the currently last-seen sample value. Note that while this
returns you an integer result, it might be further away from the "true"
rate due to the lack of extrapolation, because the two samples you will be
comparing will not be exactly 1m apart.
On Sun, May 24, 2020 at 4:05 PM tomeri <[email protected]> wrote:
> Hi,
>
> I run an application that export metrics about the total number of lines
> of each file in my directory, basically the product of `wc -l`
> So on each interval (every 1m) my app counts the total number of lines and
> then updates the Gague metric.
>
> For example:
> First iteration: 1000 total lines
> Second iteration: 1300 total lines
> Third iteration: 1900 total lines
> Fourth iteration: 2400 total lines
> ...
>
> Prometheus scraps my app's metric every 15s/25s (depends on the env)
> What i want to plot is a graph that will show the rate per minute - how
> many lines produced in each file for that last 1 minute.
>
> No matter what I tried, I couldn't make the graph to show to correct
> results.
>
> This message may contain confidential and/or privileged information.
> If you are not the addressee or authorized to receive this on behalf of
> the addressee you must not use, copy, disclose or take action based on this
> message or any information herein.
> If you have received this message in error, please advise the sender
> immediately by reply email and delete this message. Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/4d971809-72e0-4f36-b0cf-0e9914a2d251%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/4d971809-72e0-4f36-b0cf-0e9914a2d251%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Julius Volz
PromLabs - promlabs.com
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/CAObpH5whhRJN%2BOTsehL_aorzR7JzNKynz%3DXfqAbV_%2BCuSTkd4Q%40mail.gmail.com.