如何获得与influxdb non_negative_derivative一致的值? [英] How do I get consistent values with influxdb non_negative_derivative?

查看:321
本文介绍了如何获得与influxdb non_negative_derivative一致的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将grafana与influxdb结合使用,我试图显示某个计数器的某些值的每秒速率.如果使用non_negative_derivative(1s)函数,则速率的值似乎会根据grafana视图的时间宽度而发生巨大变化.我正在使用last选择器(但也可以使用max,因为它是一个计数器,所以具有相同的值).

Using grafana with influxdb, I am trying to show the per-second rate of some value that is a counter. If I use the non_negative_derivative(1s) function, the value of the rate seems to change dramatically depending on the time width of the grafana view. I'm using the last selector (but could also use max which is the same value since it is a counter).

具体来说,我正在使用:

Specifically, I'm using:

SELECT non_negative_derivative(last("my_counter"), 1s) FROM ...

根据 influxdb文档非负-导数:

InfluxDB计算时间序列值之间的差异,并将这些结果转换为每单位的变化率.

InfluxDB calculates the difference between chronological field values and converts those results into the rate of change per unit.

对我来说,这意味着扩展时间视图时给定点的值不应发生太大变化,因为该值应为每单位的变化率(在我的示例查询中为1s以上).

So to me, that means that the value at a given point should not change that much when expanding the time view, since the value should be rate of change per unit (1s in my example query above).

在石墨中,它们具有特定的perSecond功能,效果更好:

In graphite, they have the specific perSecond function, which works much better:

perSecond(consolidateBy(my_counter, 'max'))

关于上述Influx查询在做什么的任何想法?

Any ideas on what I'm doing wrong with the influx query above?

推荐答案

如果您希望每秒的结果保持不变,则需要GROUP BY time(1s).这样可以为您提供准确的perSecond结果.

If you want per second results that don't vary, you'll want to GROUP BY time(1s). This will give you accurate perSecond results.

请考虑以下示例:

假设计数器的值每秒都在变化

Suppose that the value of the counter at each second changes like so

0s → 1s → 2s → 3s → 4s
1  → 2  → 5  → 8  → 11

根据我们如何对上述序列进行分组,我们将看到不同的结果.

Depending on how we group the sequence above, we'll see different results.

考虑将事物分组到2s存储桶中的情况.

Consider the case where we group things into 2s buckets.

 0s-2s   →    2s-4s
(5-1)/2  →  (11-5)/2
   2     →      3

相对于1s存储桶

 0s-1s  →  1s-2s  →  2s-3s  →  3s-4s
(2-1)/1 → (5-2)/1 → (8-5)/1 → (11-8)/1
   1    →    3    →    3    →    3

寻址

对我来说,这意味着扩展时间视图时给定点的值不应发生太大变化,因为该值应为每单位的变化率(在上面的示例查询中为1s).

So to me, that means that the value at a given point should not change that much when expanding the time view, since the value should be rate of change per unit (1s in my example query above).

rate of change per unit是归一化因子,与GROUP BY时间单位无关.当我们将导数间隔更改为2s时,解释我们先前的示例可能会提供一些见识.

The rate of change per unit is a normalizing factor, independent of the GROUP BY time unit. Interpreting our previous example when we change the derivative interval to 2s may offer some insight.

确切的等式是

∆y/(∆x/tu)

请考虑将事物分组为导数间隔为2s1s个存储桶的情况.我们应该看到的结果是

Consider the case where we group things into 1s buckets with a derivative interval of 2s. The result we should see is

 0s-1s    →  1s-2s    →  2s-3s    →  3s-4s
2*(2-1)/1 → 2*(5-2)/1 → 2*(8-5)/1 → (11-8)/1
   2      →    6      →    6      →    6

这似乎有些奇怪,但是如果您考虑一下这应该是有道理的.当我们指定导数间隔为2s时,我们要求的是1s GROUP BY存储桶的2s变化率.

This may seem a bit odd, but if you consider what this says it should make sense. When we specify a derivative interval of 2s what we're asking for is what the 2s rate of change is for the 1s GROUP BY bucket.

如果我们对导数间隔为2s2s个存储桶应用类似的推理,则

If we apply similar reasoning to the case of 2s buckets with a derivative interval of 2s is then

 0s-2s     →    2s-4s
2*(5-1)/2  →  2*(11-5)/2
   4       →      6

我们要的是2s GROUP BY存储桶的2s变化率,在第一个间隔中,2s的变化率将是4,第二个间隔2s的变化率应为6.

What we're asking for here is what the 2s rate of change is for the 2s GROUP BY bucket and in the first interval the 2s rate of change would be 4 and the second interval the 2s rate of change would be 6.

这篇关于如何获得与influxdb non_negative_derivative一致的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆