使用新的Flux语言,如何最好地计算正常运行时间?我当前的 Flux 查询看起来有点像这样:
from(bucket: "my-bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "process_start_time_seconds")
|> filter(fn: (r) => r["_field"] == "gauge")
|> map(fn: (r) => ({
r with
_value: (int(v: now()) / 1000000000) - int(v: r._value)
})
)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
这很有效,但对于这么小的东西来说似乎非常复杂,在 Prometheus 中它基本上是一行:
(time() - process_start_time_seconds{job="my-job"})
有没有办法改进 Flux 查询?