Skip to content

Commit

Permalink
Cherry pick changes from #4269, #4303 and #4318 onto main.
Browse files Browse the repository at this point in the history
This does not include the associated integration test changes, or
changes to tests that have not yet been merged to main.
  • Loading branch information
charleskorn committed Mar 3, 2023
1 parent 6b3e5b8 commit 64dc972
Show file tree
Hide file tree
Showing 6 changed files with 718 additions and 402 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Querying with using `{__mimir_storage__="ephemeral"}` selector no longer works.
* [ENHANCEMENT] Store-gateway: Reduce memory allocation rate when loading TSDB chunks from Memcached. #4074
* [ENHANCEMENT] Query-frontend: track `cortex_frontend_query_response_codec_duration_seconds` and `cortex_frontend_query_response_codec_payload_bytes` metrics to measure the time taken and bytes read / written while encoding and decoding query result payloads. #4110
* [ENHANCEMENT] Alertmanager: expose additional upstream metrics `cortex_alertmanager_dispatcher_aggregation_groups`, `cortex_alertmanager_dispatcher_alert_processing_duration_seconds`. #4151
* [ENHANCEMENT] Querier and query-frontend: add experimental, more performant protobuf query result response format enabled with `-query-frontend.query-result-response-format=protobuf`. #4153
* [ENHANCEMENT] Querier and query-frontend: add experimental, more performant protobuf query result response format enabled with `-query-frontend.query-result-response-format=protobuf`. #4153 #4304 #4318
* [ENHANCEMENT] Store-gateway: use more efficient chunks fetching and caching. This should reduce CPU, memory utilization, and receive bandwidth of a store-gateway. Enable with `-blocks-storage.bucket-store.chunks-cache.fine-grained-chunks-caching-enabled=true`. #4163 #4174 #4227
* [ENHANCEMENT] Query-frontend: Wait for in-flight queries to finish before shutting down. #4073 #4170
* [ENHANCEMENT] Store-gateway: added `encode` and `other` stage to `cortex_bucket_store_series_request_stage_duration_seconds` metric. #4179
Expand Down
33 changes: 21 additions & 12 deletions pkg/frontend/querymiddleware/codec_protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (f protobufFormat) decodeScalarData(data *mimirpb.ScalarData) *PrometheusDa
}

func (f protobufFormat) decodeVectorData(data *mimirpb.VectorData) (*PrometheusData, error) {
streams := make([]SampleStream, len(data.Samples))
streams := make([]SampleStream, len(data.Samples)+len(data.Histograms))

for i, sample := range data.Samples {
l, err := labelsFromStringArray(sample.Metric)
Expand All @@ -114,6 +114,23 @@ func (f protobufFormat) decodeVectorData(data *mimirpb.VectorData) (*PrometheusD
}
}

for i, sample := range data.Histograms {
l, err := labelsFromStringArray(sample.Metric)
if err != nil {
return nil, err
}

streams[i+len(data.Samples)] = SampleStream{
Labels: l,
Histograms: []mimirpb.FloatHistogramPair{
{
TimestampMs: sample.TimestampMs,
Histogram: sample.Histogram,
},
},
}
}

return &PrometheusData{
ResultType: model.ValVector.String(),
Result: streams,
Expand All @@ -129,18 +146,10 @@ func (f protobufFormat) decodeMatrixData(data *mimirpb.MatrixData) (*PrometheusD
return nil, err
}

samples := make([]mimirpb.Sample, len(series.Samples))

for sampleIdx, sample := range series.Samples {
samples[sampleIdx] = mimirpb.Sample{
TimestampMs: sample.TimestampMs,
Value: sample.Value,
}
}

streams[seriesIdx] = SampleStream{
Labels: l,
Samples: samples,
Labels: l,
Samples: series.Samples,
Histograms: series.Histograms,
}
}

Expand Down
Loading

0 comments on commit 64dc972

Please sign in to comment.