-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Limiting query start time with config #572
Changes from 1 commit
30e4c65
246dba8
989c7be
ecb6e27
6d5d6e2
60a6f64
71112f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package querier | |
import ( | ||
"context" | ||
"flag" | ||
"time" | ||
|
||
"github.com/cortexproject/cortex/pkg/chunk" | ||
cortex_client "github.com/cortexproject/cortex/pkg/ingester/client" | ||
|
@@ -18,10 +19,12 @@ import ( | |
|
||
// Config for a querier. | ||
type Config struct { | ||
MaxLookBackPeriod time.Duration `yaml:"max_look_back_period"` | ||
} | ||
|
||
// RegisterFlags register flags. | ||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
f.DurationVar(&cfg.MaxLookBackPeriod, "querier.max-look_back_period", 0, "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the mixure of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. must be a typo, sorry missed it somehow |
||
} | ||
|
||
// Querier handlers queries. | ||
|
@@ -92,6 +95,11 @@ func (q *Querier) forAllIngesters(f func(logproto.QuerierClient) (interface{}, e | |
|
||
// Query does the heavy lifting for an actual query. | ||
func (q *Querier) Query(ctx context.Context, req *logproto.QueryRequest) (*logproto.QueryResponse, error) { | ||
oldestStartTime := time.Now().Add(-q.cfg.MaxLookBackPeriod) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means queries are broken for the default value (0). Have a check for |
||
if oldestStartTime.After(req.Start) { | ||
req.Start = oldestStartTime | ||
} | ||
|
||
ingesterIterators, err := q.queryIngesters(ctx, req) | ||
if err != nil { | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment above the field too?