Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Validates label matchers in the querier #601

Merged
merged 1 commit into from
Mar 29, 2023
Merged
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
14 changes: 14 additions & 0 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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"))
}
Expand Down