Skip to content

Commit

Permalink
Validate max_query_length in Label API (#2572)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityacs authored Sep 1, 2020
1 parent ab2dc9e commit c1f07f0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ func (q *Querier) queryIngestersForSample(ctx context.Context, params logql.Sele

// Label does the heavy lifting for a Label query.
func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error) {
userID, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, err
}

if err = q.validateQueryTimeRange(userID, *req.Start, *req.End); err != nil {
return nil, err
}

// Enforce the query timeout while querying backends
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(q.cfg.QueryTimeout))
defer cancel()
Expand All @@ -292,11 +301,6 @@ func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logpr
return nil, err
}

userID, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, err
}

from, through := model.TimeFromUnixNano(req.Start.UnixNano()), model.TimeFromUnixNano(req.End.UnixNano())
var storeValues []string
if req.Values {
Expand Down

0 comments on commit c1f07f0

Please sign in to comment.