两个数据点之间的Grafana差异

Grafana difference between two datapoints

在具有多个数据点的 Graphana 仪表板中,如何获取同一指标的最后一个值和前一个值之间的差异? 也许棘手的部分是不知道同一指标的 2 个数据点之间的时间。

所以期望的结果是度量字符串中每个点的 <metric>.$current_value - <metric>.$previouse_value

编辑: 指标存储在 graphite/Carbon 数据库中。

谢谢

您需要使用derivative功能

This is the opposite of the integral function. This is useful for taking a running total metric and calculating the delta between subsequent data points.

This function does not normalize for periods of time, as a true derivative would. Instead see the perSecond() function to calculate a rate of change over time.

连同 keepLastValue

Takes one metric or a wildcard seriesList, and optionally a limit to the number of ‘None’ values to skip over.

Continues the line with the last received value when gaps (‘None’ values) appear in your data, rather than breaking your line.

像这样

derivative(keepLastValue(your_mteric))

可以在这里找到一个很好的例子http://www.perehospital.cat/blog/graphite-getting-derivative-to-work-with-empty-data-points