Skip to content

Commit

Permalink
MQE: only reduce resolution of delta in rate and increase once (#…
Browse files Browse the repository at this point in the history
…9531)

* Only reduce resolution of delta once if schema changes multiple times in range

* Add changelog entry
  • Loading branch information
charleskorn authored Oct 8, 2024
1 parent cabc3ee commit c4cd8d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* `cortex_alertmanager_alerts`
* `cortex_alertmanager_silences`
* [CHANGE] Cache: Deprecate experimental support for Redis as a cache backend. #9453
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9532 #9533
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9531 #9532 #9533
* [FEATURE] Query-frontend: added experimental configuration options `query-frontend.cache-errors` and `query-frontend.results-cache-ttl-for-errors` to allow non-transient responses to be cached. When set to `true` error responses from hitting limits or bad data are cached for a short TTL. #9028
* [FEATURE] gRPC: Support S2 compression. #9322
* `-alertmanager.alertmanager-client.grpc-compression=s2`
Expand Down
16 changes: 10 additions & 6 deletions pkg/streamingpromql/functions/rate_increase.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ func histogramRate(isRate bool, step types.RangeVectorStepData, hHead []promql.H
emitAnnotation(annotations.NewNativeHistogramNotCounterWarning)
}

initialSchema := firstPoint.H.Schema
if lastPoint.H.Schema < initialSchema {
initialSchema = lastPoint.H.Schema
desiredSchema := firstPoint.H.Schema
if lastPoint.H.Schema < desiredSchema {
desiredSchema = lastPoint.H.Schema
}

usingCustomBuckets := firstPoint.H.UsesCustomBuckets()
if lastPoint.H.UsesCustomBuckets() != usingCustomBuckets {
return nil, histogram.ErrHistogramsIncompatibleSchema
}

delta := lastPoint.H.CopyToSchema(initialSchema)
delta := lastPoint.H.CopyToSchema(desiredSchema)
_, err := delta.Sub(firstPoint.H)
if err != nil {
return nil, err
Expand All @@ -114,8 +114,8 @@ func histogramRate(isRate bool, step types.RangeVectorStepData, hHead []promql.H
return histogram.ErrHistogramsIncompatibleSchema
}

if p.H.Schema < delta.Schema {
delta = delta.CopyToSchema(p.H.Schema)
if p.H.Schema < desiredSchema {
desiredSchema = p.H.Schema
}

if p.H.CounterResetHint == histogram.GaugeType {
Expand All @@ -138,6 +138,10 @@ func histogramRate(isRate bool, step types.RangeVectorStepData, hHead []promql.H

}

if delta.Schema != desiredSchema {
delta = delta.CopyToSchema(desiredSchema)
}

val := calculateHistogramRate(isRate, step.RangeStart, step.RangeEnd, rangeSeconds, firstPoint, lastPoint, delta, hCount)
return val, err
}
Expand Down

0 comments on commit c4cd8d1

Please sign in to comment.