Skip to content
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

Add support for label matchers in LabelNames and LabelValues call to store. #4107

Merged
merged 8 commits into from
Apr 27, 2021

Conversation

pstibrany
Copy link
Contributor

@pstibrany pstibrany commented Apr 26, 2021

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

This PR implements support for label matches in LabelNames and LabelValues API calls to bucket store. It reuses existing blockSeries implementation, but without fetching of chunks.

Verification

Unit tests.

This is a partial fix for issue #3637

indexr *bucketIndexReader,
chunkr *bucketChunkReader,
matchers []*labels.Matcher,
req *storepb.SeriesRequest,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of req we now pass all used parameters explicitly.


s.mtx.RLock()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that s.mtx.RLock() is now only called after checking hints. Previously wrong hints would return error without unlocking this lock.

yeya24
yeya24 previously approved these changes Apr 26, 2021
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the great work.

pkg/store/bucket.go Outdated Show resolved Hide resolved
pkg/store/bucket.go Show resolved Hide resolved
pkg/store/bucket.go Show resolved Hide resolved
pkg/store/bucket.go Show resolved Hide resolved
yeya24
yeya24 previously approved these changes Apr 27, 2021
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the great work!

pracucci
pracucci previously approved these changes Apr 27, 2021
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job! 👏 LGTM

The failing TestTargetsAPI_Fanout is known to be flaky. Unrelated from this change.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
…n use that.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
@pracucci pracucci dismissed stale reviews from yeya24 and themself via 84c4e5a April 27, 2021 15:17
@pracucci
Copy link
Contributor

I've just rebased master. Let's see if CI passes now.

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving again. @yeya24 also approved and only the rebase has been done in the meanwhile.

@@ -1261,7 +1302,25 @@ func (s *BucketStore) LabelValues(ctx context.Context, req *storepb.LabelValuesR
}
}

// If we have series matchers, add <labelName> != "" matcher, to only select series that have given label name.
if len(reqSeriesMatchers) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if reqSeriesMatchers already contains this unequal matcher? @pstibrany @pracucci

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End result will be correct, but there is an optimization we can do (preferably in blockSeries to be more general).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants