以秒为单位绘制当前持续时间

Graph the current duration in second

我想显示从范围开始到结束的总持续时间(以秒为单位)。

该图将总持续时间(以秒为单位)作为 Y 轴,时间作为 X 轴。

它会从 0s 开始到 3600s,范围为一小时。

我设法基于 Graphite 系列绘制它,但是当范围太宽时它是不正确的。我猜这与一段时间后数据的清理有关。

Graphite 包含一个名为 timeFunction which just returns the timestamp for every point in the graph, at an interval you choose. Combined with the offsetToZero function, you can draw a line that counts up in standard time increments and starts at 0 regardless of the duration of the graph 的函数。它看起来像这样:

offsetToZero(timeFunction('duration', 60))

我在长达 90 天的时间和各种 maxdataPoint 值下对此进行了测试,它似乎工作正常。 60 秒是 timeFunction 的默认间隔,但您可以使用任何您喜欢的时间间隔,具体取决于您认为对仪表盘而言合适的时间间隔。

如果您使用的是不同版本的 Graphite,并且在不同的缩放级别下仍然看到值看起来很奇怪,请尝试添加 consolidateBy(max) 以确保在合并数据点时使用最高值而不是平均值。您还可以 consolidateBy(min) - Graphite 数据点表示接下来的时间段而不是之前的时间段,因此第一个数据点在数学上可能更正确,具体取决于您的实现。

(注意:发生数据点合并是因为 Grafana 将 maxDataPoints 值及其请求发送到 Grafana,这样 Graphite 就不会 return 图表可以显示的更多数据点。)