-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Loki: Series API will return all series with no match or empty matcher #2254
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 |
---|---|---|
|
@@ -148,9 +148,24 @@ func (s *store) lazyChunks(ctx context.Context, matchers []*labels.Matcher, from | |
} | ||
|
||
func (s *store) GetSeries(ctx context.Context, req logql.SelectParams) ([]logproto.SeriesIdentifier, error) { | ||
matchers, _, from, through, err := decodeReq(req) | ||
if err != nil { | ||
return nil, err | ||
var from, through model.Time | ||
var matchers []*labels.Matcher | ||
|
||
// The Loki parser doesn't allow for an empty label matcher but for the Series API | ||
// we allow this to select all series in the time range. | ||
if req.Selector == "" { | ||
from, through = util.RoundToMilliseconds(req.Start, req.End) | ||
nameLabelMatcher, err := labels.NewMatcher(labels.MatchEqual, labels.MetricName, "logs") | ||
if err != nil { | ||
return nil, err | ||
} | ||
matchers = []*labels.Matcher{nameLabelMatcher} | ||
Comment on lines
+157
to
+162
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. One concern I have here is this shortcut also skips the shard aware stuff in decodeReq, currently the series API is not shard aware so this is fine but I'm not sure if there is something else we could do here to protect future us from missing this. See #2167 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. You would need to get the part that parses the string matcher out and pass the matchers as an array to decodeReq. |
||
} else { | ||
var err error | ||
matchers, _, from, through, err = decodeReq(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
lazyChunks, err := s.lazyChunks(ctx, matchers, from, through) | ||
|
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.
This allocation isn't protected by a mutex so it could be wrong but I think this would generally be ok, worst case a stream is added between the creation of this array and it's population causing Go to have to double its size. I'm thinking this is ok but am open to alternatives or different opinions.
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.
No problem here from my point of view. But if you're not sure you can write a test that does 2 query in different goroutine and run that test using -race.
go test -mod=vendor -race ./pkg/ingester
.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.
I think you could have kept the same function
func(stream *stream) error
for both cases.`