Skip to content

Commit

Permalink
MQE: fix issue where rate or increase can return multiple series …
Browse files Browse the repository at this point in the history
…with the same labels (#9553) (#9556)

* Fix the issue where `rate` or `increase` can return multiple series with the same labels

* Add changelog entry

* Disable unsupported upstream test case

(cherry picked from commit 25dadff)

# Conflicts:
#	CHANGELOG.md
#	pkg/streamingpromql/functions/rate.go
#	pkg/streamingpromql/testdata/ours/functions.test
  • Loading branch information
charleskorn authored Oct 8, 2024
1 parent ce7c972 commit 63d57d2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* [CHANGE] Query-scheduler: Remove the experimental `-query-scheduler.use-multi-algorithm-query-queue` flag. The new multi-algorithm tree queue is always used for the scheduler. #9210
* [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 #9371 #9482 #9518
* [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 #9371 #9482 #9518 #9553
* [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.
Expand Down
1 change: 1 addition & 0 deletions pkg/streamingpromql/functions/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var Rate = FunctionOverRangeVector{
SeriesValidationFuncFactory: rateSeriesValidator,
SeriesMetadataFunc: DropSeriesName,
NeedsSeriesNamesForAnnotations: true,
NeedsSeriesDeduplication: true,
}

func rate(step types.RangeVectorStepData, rangeSeconds float64, floatBuffer *types.FPointRingBuffer, histogramBuffer *types.HPointRingBuffer, emitAnnotation EmitAnnotationFunc) (float64, bool, *histogram.FloatHistogram, error) {
Expand Down
105 changes: 105 additions & 0 deletions pkg/streamingpromql/testdata/ours/functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,108 @@ load 1m

eval range from 0 to 7m step 1m -metric
{} -1 -1 -1 -3 -3 _ -4 -4

clear

# Test the case where multiple series have the same labels after the metric name is removed by a function.
load 1m
float_metric_1 0+1x4
float_metric_2 0+2x4
histogram_metric_1 {{sum:0 count:0}}x4
histogram_metric_2 {{sum:1 count:1}}x4

eval_fail instant at 5m abs({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m acos({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m acosh({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m asin({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m asinh({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m atan({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m atanh({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m avg_over_time({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m ceil({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m cos({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m cosh({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m count_over_time({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m deg({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m exp({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m floor({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m histogram_count({__name__=~"histogram_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m histogram_sum({__name__=~"histogram_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m max_over_time({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m min_over_time({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m ln({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m log10({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m log2({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m present_over_time({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m rad({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m rate({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m sgn({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m sin({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m sinh({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m sqrt({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m sum_over_time({__name__=~"float_metric_.*"}[5m])
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m tan({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset

eval_fail instant at 5m tanh({__name__=~"float_metric_.*"})
expected_fail_message vector cannot contain metrics with the same labelset
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ eval instant at 15m sum by (__name__, env) (metric{env="1"})

# Aggregation operators aggregate metrics with same labelset and to-be-dropped names
# This is an accidental side effect of delayed __name__ label dropping
eval instant at 15m sum(rate({env="1"}[10m])) by (env)
{env="1"} 0.4
# Unsupported by streaming engine.
# eval instant at 15m sum(rate({env="1"}[10m])) by (env)
# {env="1"} 0.4

# Aggregationk operators propagate __name__ label dropping information
# Unsupported by streaming engine.
Expand Down

0 comments on commit 63d57d2

Please sign in to comment.