diff --git a/CHANGELOG.md b/CHANGELOG.md index 96b7671bc54..c7f5c09814c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ * [CHANGE] Distributor: reject incoming requests until the distributor service has started. #9317 * [FEATURE] Alertmanager: Added `-alertmanager.log-parsing-label-matchers` to control logging when parsing label matchers. This flag is intended to be used with `-alertmanager.utf8-strict-mode-enabled` to validate UTF-8 strict mode is working as intended. The default value is `false`. #9173 * [FEATURE] Alertmanager: Added `-alertmanager.utf8-migration-logging-enabled` to enable logging of tenant configurations that are incompatible with UTF-8 strict mode. The default value is `false`. #9174 -* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #8422 #8430 #8454 #8455 #8360 #8490 #8508 #8577 #8660 #8671 #8677 #8747 #8850 #8872 #8838 #8911 #8909 #8923 #8924 #8925 #8932 #8933 #8934 #8962 #8986 #8993 #8995 #9008 #9017 #9018 #9019 #9120 #9121 #9136 #9139 #9140 #9145 #9191 #9192 #9194 #9196 #9201 #9212 #9225 #9260 #9272 #9277 #9278 #9280 #9281 #9342 #9343 +* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #8422 #8430 #8454 #8455 #8360 #8490 #8508 #8577 #8660 #8671 #8677 #8747 #8850 #8872 #8838 #8911 #8909 #8923 #8924 #8925 #8932 #8933 #8934 #8962 #8986 #8993 #8995 #9008 #9017 #9018 #9019 #9120 #9121 #9136 #9139 #9140 #9145 #9191 #9192 #9194 #9196 #9201 #9212 #9225 #9260 #9272 #9277 #9278 #9280 #9281 #9342 #9343 #9371 * [FEATURE] Experimental Kafka-based ingest storage. #6888 #6894 #6929 #6940 #6951 #6974 #6982 #7029 #7030 #7091 #7142 #7147 #7148 #7153 #7160 #7193 #7349 #7376 #7388 #7391 #7393 #7394 #7402 #7404 #7423 #7424 #7437 #7486 #7503 #7508 #7540 #7621 #7682 #7685 #7694 #7695 #7696 #7697 #7701 #7733 #7734 #7741 #7752 #7838 #7851 #7871 #7877 #7880 #7882 #7887 #7891 #7925 #7955 #7967 #8031 #8063 #8077 #8088 #8135 #8176 #8184 #8194 #8216 #8217 #8222 #8233 #8503 #8542 #8579 #8657 #8686 #8688 #8703 #8706 #8708 #8738 #8750 #8778 #8808 #8809 #8841 #8842 #8845 #8853 #8886 #8988 * What it is: * When the new ingest storage architecture is enabled, distributors write incoming write requests to a Kafka-compatible backend, and the ingesters asynchronously replay ingested data from Kafka. In this architecture, the write and read path are de-coupled through a Kafka-compatible backend. The write path and Kafka load is a function of the incoming write traffic, the read path load is a function of received queries. Whatever the load on the read path, it doesn't affect the write path. diff --git a/pkg/streamingpromql/functions/rate.go b/pkg/streamingpromql/functions/rate.go index 3352d84c0aa..10dce2f01ca 100644 --- a/pkg/streamingpromql/functions/rate.go +++ b/pkg/streamingpromql/functions/rate.go @@ -42,7 +42,7 @@ func rate(step types.RangeVectorStepData, rangeSeconds float64, floatBuffer *typ } if hCount >= 2 { - val, err := histogramRate(histogramBuffer, step, hHead, hTail, rangeSeconds, hCount, emitAnnotation) + val, err := histogramRate(step, hHead, hTail, rangeSeconds, hCount, emitAnnotation) if err != nil { err = NativeHistogramErrorToAnnotation(err, emitAnnotation) return 0, false, nil, err @@ -53,9 +53,15 @@ func rate(step types.RangeVectorStepData, rangeSeconds float64, floatBuffer *typ return 0, false, nil, nil } -func histogramRate(histogramBuffer *types.HPointRingBuffer, step types.RangeVectorStepData, hHead []promql.HPoint, hTail []promql.HPoint, rangeSeconds float64, hCount int, emitAnnotation EmitAnnotationFunc) (*histogram.FloatHistogram, error) { - firstPoint := histogramBuffer.First() - usingCustomBuckets := firstPoint.H.UsesCustomBuckets() +func histogramRate(step types.RangeVectorStepData, hHead []promql.HPoint, hTail []promql.HPoint, rangeSeconds float64, hCount int, emitAnnotation EmitAnnotationFunc) (*histogram.FloatHistogram, error) { + var firstPoint promql.HPoint + if len(hHead) > 0 { + firstPoint = hHead[0] + hHead = hHead[1:] + } else { + firstPoint = hTail[0] + hTail = hTail[1:] + } var lastPoint promql.HPoint if len(hTail) > 0 { @@ -73,6 +79,7 @@ func histogramRate(histogramBuffer *types.HPointRingBuffer, step types.RangeVect currentSchema = lastPoint.H.Schema } + usingCustomBuckets := firstPoint.H.UsesCustomBuckets() if lastPoint.H.UsesCustomBuckets() != usingCustomBuckets { return nil, histogram.ErrHistogramsIncompatibleSchema } diff --git a/pkg/streamingpromql/testdata/ours/native_histograms.test b/pkg/streamingpromql/testdata/ours/native_histograms.test index ce4be635e22..8e2c64b4e61 100644 --- a/pkg/streamingpromql/testdata/ours/native_histograms.test +++ b/pkg/streamingpromql/testdata/ours/native_histograms.test @@ -147,6 +147,15 @@ eval range from 0 to 4m step 1m sum by (env) (rate(incr_histogram[5m])) clear +# Test rate() with explicit counter reset information. +load 1m + metric {{sum:3 count:4 buckets:[1 2 1] counter_reset_hint:reset}} {{sum:63 count:124 buckets:[100 4 20] counter_reset_hint:not_reset}} + +eval instant at 1m rate(metric[1m]) + {} {{sum:1 count:2 buckets:[1.65 0.03333333333333333 0.31666666666666665] counter_reset_hint:gauge}} + +clear + # Test mixing exponential and custom buckets. load 6m metric{series="exponential"} {{sum:4 count:5 buckets:[1 3 1]}} _ {{sum:4 count:5 buckets:[1 3 1]}} {{sum:4 count:5 buckets:[1 3 1]}} _