-
Notifications
You must be signed in to change notification settings - Fork 816
limit get series API call time range when start param is not specified #4976
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
Changes from all commits
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 |
---|---|---|
|
@@ -335,6 +335,12 @@ func (q querier) Select(sortSeries bool, sp *storage.SelectHints, matchers ...*l | |
sp.Start = startMs | ||
sp.End = endMs | ||
|
||
// For series queries without specifying the start time, we prefer to | ||
// only query ingesters and not to query maxQueryLength to avoid OOM kill. | ||
if sp.Func == "series" && startMs == 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. I think it's better if we merge this to line 307 above. Because what they are doing are pretty much the same. 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. I see. I wanted to merge the two but to do this we need to do L318 ~ L336 first before L307. 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. I was thinking we can do something along the line
Essentially if start is There is an edge case where user actually specifies "0" for "start", and Cortex would still return last 24 hours data, but I think this behaviour is ok for the edge case. 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. OK, I think this could work... 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. Yea that's why I was thinking maybe I think this PR is ok, but I will let @alanprot have a chance to voice any other concerns based on what I said :) |
||
return q.metadataQuerier.Select(true, sp, matchers...) | ||
} | ||
|
||
startTime := model.Time(startMs) | ||
endTime := model.Time(endMs) | ||
|
||
|
@@ -390,7 +396,7 @@ func (q querier) Select(sortSeries bool, sp *storage.SelectHints, matchers ...*l | |
return seriesSet | ||
} | ||
|
||
// LabelsValue implements storage.Querier. | ||
// LabelValues implements storage.Querier. | ||
func (q querier) LabelValues(name string, matchers ...*labels.Matcher) ([]string, storage.Warnings, error) { | ||
if !q.queryStoreForLabels { | ||
return q.metadataQuerier.LabelValues(name, matchers...) | ||
|
@@ -639,6 +645,11 @@ func validateQueryTimeRange(ctx context.Context, userID string, startMs, endMs i | |
} | ||
} | ||
|
||
// start time should be at least non-negative to avoid int64 overflow. | ||
if startTime < 0 { | ||
startTime = 0 | ||
} | ||
|
||
return int64(startTime), int64(endTime), nil | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.