Skip to content

Commit

Permalink
Add a way to control the aggregation type for the SelectSeries API (#…
Browse files Browse the repository at this point in the history
…2758)

* Add mergeFunction to the SelectSeries API

* Rename mergeFunction to aggregation, make it optional

* Rename accumulator to aggregator

* Use aggregation param in series merger as well

* Switch to an enum for the time series aggregation type

* Restore removed doc

* Add aggregation to frontend state

* Fix formatting

* Simplify series aggregation:

- perform only sum aggregation in series merger
- retain duplicate samples in series merger (when sum=false)
- remove "first value" aggregator

* Fix issues after merge with main

* Simplify test
  • Loading branch information
aleks-p authored Dec 4, 2023
1 parent fd89bda commit b9966bd
Showing 22 changed files with 837 additions and 452 deletions.
597 changes: 307 additions & 290 deletions api/gen/proto/go/ingester/v1/ingester.pb.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions api/gen/proto/go/ingester/v1/ingester_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

222 changes: 119 additions & 103 deletions api/gen/proto/go/querier/v1/querier.pb.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions api/gen/proto/go/querier/v1/querier_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 84 additions & 28 deletions api/gen/proto/go/types/v1/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/ingester/v1/ingester.proto
Original file line number Diff line number Diff line change
@@ -59,6 +59,8 @@ message SelectProfilesRequest {
int64 end = 4;
// Optional: Hints for querying
optional Hints hints = 5;
// Optional: Aggregation
optional types.v1.TimeSeriesAggregationType aggregation = 6;
}

message MergeProfilesStacktracesRequest {
12 changes: 12 additions & 0 deletions api/openapiv2/gen/phlare.swagger.json
Original file line number Diff line number Diff line change
@@ -1001,6 +1001,10 @@
"hints": {
"$ref": "#/definitions/v1Hints",
"title": "Optional: Hints for querying"
},
"aggregation": {
"$ref": "#/definitions/v1TimeSeriesAggregationType",
"title": "Optional: Aggregation"
}
}
},
@@ -1100,6 +1104,14 @@
],
"default": "MERGE_FORMAT_UNSPECIFIED"
},
"v1TimeSeriesAggregationType": {
"type": "string",
"enum": [
"TIME_SERIES_AGGREGATION_TYPE_SUM",
"TIME_SERIES_AGGREGATION_TYPE_AVERAGE"
],
"default": "TIME_SERIES_AGGREGATION_TYPE_SUM"
},
"v1ValueType": {
"type": "object",
"properties": {
1 change: 1 addition & 0 deletions api/querier/v1/querier.proto
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@ message SelectSeriesRequest {
int64 end = 4; // milliseconds since epoch
repeated string group_by = 5;
double step = 6; // Query resolution step width in seconds
optional types.v1.TimeSeriesAggregationType aggregation = 7;
}

message SelectSeriesResponse {
5 changes: 5 additions & 0 deletions api/types/v1/types.proto
Original file line number Diff line number Diff line change
@@ -66,3 +66,8 @@ message BlockCompaction {
repeated string sources = 2;
repeated string parents = 3;
}

enum TimeSeriesAggregationType {
TIME_SERIES_AGGREGATION_TYPE_SUM = 0;
TIME_SERIES_AGGREGATION_TYPE_AVERAGE = 1;
}
1 change: 1 addition & 0 deletions pkg/frontend/frontend_select_series.go
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ func (f *Frontend) SelectSeries(ctx context.Context,
End: r.End.UnixMilli(),
GroupBy: c.Msg.GroupBy,
Step: c.Msg.Step,
Aggregation: c.Msg.Aggregation,
})
resp, err := connectgrpc.RoundTripUnary[
querierv1.SelectSeriesRequest,
Loading

0 comments on commit b9966bd

Please sign in to comment.