[Feature request] Support Prometheus-compatible PromQL rate(), irate(), increase(), and delta() for range vectors
@CoollZzz ci sta già lavorando.
Dal 17/6/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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!
- Lingua principale
- Java
- Stelle
- 6.4k
- Fork
- 1.2k
- Merge medio
- 1g 17h
- PR unite (30g)
- 152
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/iotdb
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports success Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column name Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Tutte le issue di apache/iotdb
Issue simili
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/flink-agents#1156 ·
-
[source-shopify] FAILED bulk operation without partialDataUrl is silently treated as successful Apertaarea/connectors autoteam community connectors/source/shopify needs-triage team/use type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100