[Feature request] Support Prometheus-compatible PromQL rate(), irate(), increase(), and delta() for range vectors
@CoollZzz 已经在做这个了。
开始于 2026年6月17日。
评估
这个 Issue 还没有评估数据。
描述
Search before asking
- I searched in the issues and found nothing similar.
Motivation
Description
IoTDB should support Prometheus-compatible semantics for the PromQL rate(), irate(), increase(), and delta() functions on range vectors.
The expected behavior should follow Prometheus:
rate(v range-vector)returns the per-second average rate of increase over the selected range.irate(v range-vector)returns the per-second instant rate based on the last two samples in the selected range.increase(v range-vector)returns the total increase over the selected range.delta(v range-vector)returns the difference between the first and last values over the selected range.rate(),irate(), andincrease()should be used with counters and should handle counter resets correctly.delta()should be used with gauges and should not apply counter-reset correction.rate(),increase(), anddelta()should use all samples in the range and extrapolate to the range boundaries.irate()should use only the last two samples and should not extrapolate to range boundaries.
Expected Implementation Semantics
For rate() on float counters:
- Require at least two samples.
- Compute the raw increase as
last - first. - For each adjacent sample pair, detect counter reset when
current < previous. - For each detected reset, add the previous value to the corrected increase.
- If start timestamp metadata is available, also treat start timestamp reset as a counter reset.
- Apply Prometheus-compatible boundary extrapolation.
- Divide by the full range duration in seconds.
For increase() on float counters:
- Require at least two samples.
- Use the same counter-reset correction and boundary extrapolation logic as
rate(). - Return the extrapolated total increase over the range.
- Do not divide by the range duration.
- The result should be equivalent to
rate(v) * rangeDurationSeconds.
For irate() on float counters:
- Require at least two samples.
- Use only the last two samples in the range.
- If no reset is detected, return
(last - previous) / intervalSeconds. - If reset is detected, return
last / intervalSeconds. - Do not perform range-boundary extrapolation.
For delta() on float gauges:
- Require at least two samples.
- Compute the raw delta as
last - first. - Do not apply counter-reset correction.
- Apply Prometheus-compatible boundary extrapolation to cover the full range.
- Return the extrapolated delta directly.
- Do not divide by the range duration.
Test Cases
Please add compatibility tests for:
rate()without reset.rate()with one counter reset.rate()with multiple counter resets.rate()boundary extrapolation when samples are close to the range boundaries.rate()boundary extrapolation when samples are far from the range boundaries.rate()counter zero-point extrapolation guard.increase()without reset.increase()with one counter reset.increase()with multiple counter resets.increase()boundary extrapolation.increase()producing the same value asrate(v) * rangeDurationSeconds.irate()without reset.irate()with reset between the last two samples.irate()ignoring older samples except for selecting the last two points.delta()with increasing gauge values.delta()with decreasing gauge values.delta()boundary extrapolation.delta()not treating value decreases as counter resets.- Empty result when fewer than two samples are available.
References
- Prometheus
rate()documentation: https://prometheus.io/docs/prometheus/latest/querying/functions/#rate - Prometheus
irate()documentation: https://prometheus.io/docs/prometheus/latest/querying/functions/#irate - Prometheus
increase()documentation: https://prometheus.io/docs/prometheus/latest/querying/functions/#increase - Prometheus
delta()documentation: https://prometheus.io/docs/prometheus/latest/querying/functions/#delta - Prometheus
resets()documentation: https://prometheus.io/docs/prometheus/latest/querying/functions/#resets - Prometheus implementation: https://github.com/prometheus/prometheus/blob/main/promql/functions.go
Solution
No response
Alternatives
No response
Are you willing to submit a PR?
- I'm willing to submit a PR!
- 主要语言
- Java
- 星标
- 6.4k
- 派生
- 1.2k
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 152
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/iotdb 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports success 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 78/100
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 65/100
inu-appcenter/memorIN-backend#288 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
-
frontend maui-pilot pilot-ask question
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
area/plugin
难度 2/5 1-3 小时 新手友好度 75/100
kestra-io/plugin-kestra#190 ·