Skip to content

feat: add limit to SelectSeries API #3602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 142 additions & 131 deletions api/gen/proto/go/querier/v1/querier.pb.go

Large diffs are not rendered by default.

35 changes: 35 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.

141 changes: 75 additions & 66 deletions api/gen/proto/go/query/v1/query.pb.go

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

31 changes: 31 additions & 0 deletions api/gen/proto/go/query/v1/query_vtproto.pb.go

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

4 changes: 4 additions & 0 deletions api/openapiv2/gen/phlare.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2179,6 +2179,10 @@
"items": {
"type": "string"
}
},
"limit": {
"type": "string",
"format": "int64"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions api/querier/v1/querier.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ message SelectSeriesRequest {
optional types.v1.TimeSeriesAggregationType aggregation = 7;
// Select stack traces that match the provided selector.
optional types.v1.StackTraceSelector stack_trace_selector = 8;
// Select the top N series by total value.
optional int64 limit = 9;
}

message SelectSeriesResponse {
Expand Down
1 change: 1 addition & 0 deletions api/query/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ message SeriesLabelsReport {
message TimeSeriesQuery {
double step = 1;
repeated string group_by = 2;
int64 limit = 3;
}

message TimeSeriesReport {
Expand Down
3 changes: 2 additions & 1 deletion pkg/frontend/frontend_select_time_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ func (f *Frontend) SelectSeries(
return nil, err
}

return connect.NewResponse(&querierv1.SelectSeriesResponse{Series: m.TimeSeries()}), nil
series := m.Top(int(c.Msg.GetLimit()))
return connect.NewResponse(&querierv1.SelectSeriesResponse{Series: series}), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

querierv1 "github.com/grafana/pyroscope/api/gen/proto/go/querier/v1"
queryv1 "github.com/grafana/pyroscope/api/gen/proto/go/query/v1"
phlaremodel "github.com/grafana/pyroscope/pkg/model"
"github.com/grafana/pyroscope/pkg/validation"
)

Expand Down Expand Up @@ -50,6 +51,7 @@ func (q *QueryFrontend) SelectSeries(
TimeSeries: &queryv1.TimeSeriesQuery{
Step: c.Msg.GetStep(),
GroupBy: c.Msg.GetGroupBy(),
Limit: c.Msg.GetLimit(),
},
}},
})
Expand All @@ -59,5 +61,6 @@ func (q *QueryFrontend) SelectSeries(
if report == nil {
return connect.NewResponse(&querierv1.SelectSeriesResponse{}), nil
}
return connect.NewResponse(&querierv1.SelectSeriesResponse{Series: report.TimeSeries.TimeSeries}), nil
series := phlaremodel.TopSeries(report.TimeSeries.TimeSeries, int(c.Msg.GetLimit()))
return connect.NewResponse(&querierv1.SelectSeriesResponse{Series: series}), nil
}
Loading
Loading