diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index 9a31d54f9..52c1d4c7f 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -18,6 +18,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/promql/parser" "github.com/samber/lo" "golang.org/x/sync/errgroup" @@ -224,6 +225,10 @@ func (q *Querier) SelectMergeStacktraces(ctx context.Context, req *connect.Reque if err != nil { return nil, connect.NewError(connect.CodeInvalidArgument, err) } + _, err = parser.ParseMetricSelector(req.Msg.LabelSelector) + if err != nil { + return nil, connect.NewError(connect.CodeInvalidArgument, err) + } ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -280,6 +285,10 @@ func (q *Querier) SelectMergeProfile(ctx context.Context, req *connect.Request[q if err != nil { return nil, connect.NewError(connect.CodeInvalidArgument, err) } + _, err = parser.ParseMetricSelector(req.Msg.LabelSelector) + if err != nil { + return nil, connect.NewError(connect.CodeInvalidArgument, err) + } ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -338,6 +347,11 @@ func (q *Querier) SelectSeries(ctx context.Context, req *connect.Request[querier return nil, connect.NewError(connect.CodeInvalidArgument, err) } + _, err = parser.ParseMetricSelector(req.Msg.LabelSelector) + if err != nil { + return nil, connect.NewError(connect.CodeInvalidArgument, err) + } + if req.Msg.Start > req.Msg.End { return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("start must be before end")) }