Following up on Github #1335, I'd like to propose adding an integral() function to PromQL. This would be similar to sum_over_time(), except that points would not have equal weight, and instead the time-integral would be computed using the delta between points.
Ideally, a max delta would be configurable to account for resets in a gauge metric. This would be similar to InfluxDB's integral() function (http://docs.influxdata.com/influxdb/v1.6/query_language/functions/#integral).Use case: compute the integral of a gauge metric, such as kube_pod_container_resource_requests_cpu_cores, to understand the total resource usage of a Pod in Kubernetes.
Yep, for example, suppose we have a metric with points:t=0, value=2t=10, value=2t=30, value=2integral() would result in 60Unless I misunderstand how avg_over_time() works, it would return 2
On Thu, Aug 2, 2018 at 5:02 PM Brian Brazil <brian.brazil@robustperception.io> wrote:On 3 August 2018 at 00:53, <cbe...@openai.com> wrote:Following up on Github #1335, I'd like to propose adding an integral() function to PromQL. This would be similar to sum_over_time(), except that points would not have equal weight, and instead the time-integral would be computed using the delta between points.I'm unclear on what exactly you're proposing. Can you give an example of how this would work?Ideally, a max delta would be configurable to account for resets in a gauge metric.
This would be similar to InfluxDB's integral() function (http://docs.influxdata.com/influxdb/v1.6/query_language/functions/#integral).Use case: compute the integral of a gauge metric, such as kube_pod_container_resource_requests_cpu_cores, to understand the total resource usage of a Pod in Kubernetes.avg_over_time should cover that.
--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To post to this group, send email to prometheus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Note: in this toy example avg_over_time multiplied by the period generates the same value as the proposed integral function but only because the values were all the same. Since the avg_over_time function does not calculate a weighted average, it differs meaningfully from an integral.
Consider the following counter example:t=0, value=2t=1, value=2t=10, value=5
avg_over_time * period = 30integral = 47
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On 3 August 2018 at 08:57, Lucas Serven Marin <lse...@redhat.com> wrote:Note: in this toy example avg_over_time multiplied by the period generates the same value as the proposed integral function but only because the values were all the same. Since the avg_over_time function does not calculate a weighted average, it differs meaningfully from an integral.It was decided to not weight the over_time functions for simplicity, and as in the real world it is unlikely to make much of a difference.
Consider the following counter example:t=0, value=2t=1, value=2t=10, value=5The target here was down for 8 of 11 scrapes, you've got bigger problems here.
avg_over_time * period = 30integral = 47How are you getting 47 out of that, and how do you know that 47 is correct? There's multiple possible interpolations of that data.
I think you might be confusing gauges and counters.
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To post to this group, send email to prometheus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
El El vie, ago. 3, 2018 a las 10:02, Brian Brazil <brian.brazil@robustperception.io> escribió:On 3 August 2018 at 08:57, Lucas Serven Marin <lse...@redhat.com> wrote:Note: in this toy example avg_over_time multiplied by the period generates the same value as the proposed integral function but only because the values were all the same. Since the avg_over_time function does not calculate a weighted average, it differs meaningfully from an integral.It was decided to not weight the over_time functions for simplicity, and as in the real world it is unlikely to make much of a difference.No one is arguing that avg_over_time should be weighted, just stating that it doesn’t weight, which causes it to perform differently from an integral.Consider the following counter example:t=0, value=2t=1, value=2t=10, value=5The target here was down for 8 of 11 scrapes, you've got bigger problems here.Sure, but that’s entirely besides the point. The functions calculate different values.
avg_over_time * period = 30integral = 47How are you getting 47 out of that, and how do you know that 47 is correct? There's multiple possible interpolations of that data.Yes, there are multiple possible correct ways to calculate an integral depending on your definition but no matter how many examples are equal, all you need is one counter example to demonstrate that it is different from avg_over_time, which this example does.
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To post to this group, send email to prometheus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
What function returns the time period? For my specific example, avg_over_time multiplied by the period would probably be ok, but I couldn't find a function that returned the period
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To post to this group, send email to prometheus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Ah, so here's a more complete example where they won't work: I'd like to create a query of the most expensive (in terms of requested CPU) Pods in our Kubernetes cluster, in the last day. With an integral function, I would use integral(kube_pod_container_resource_requests_cpu_cores[24h]). I can't use avg_over_time(kube_pod_container_resource_requests_cpu_cores[24h])*86400, because many Pods won't have been running for the entire 24hours (our Kube cluster is used for a lot of batch jobs).
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Brian
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To post to this group, send email to prometheus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
It's directionally correct yes, but the units are unclear which would be confusing for people looking at the results: we'd expect to see core-seconds or core-hours used, but instead the units are in core-polling-intervals
Brian
Brian
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp60Yvmq4AyxxqUAe2npgcV6LZhYZ2BnUbUot7-peE%2Bmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.