Skip to content

Update Prometheus; add matchers parameter to LabelValues on ingester #3806

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

Merged
merged 5 commits into from
Feb 15, 2021

Conversation

replay
Copy link
Contributor

@replay replay commented Feb 9, 2021

This PR updates the Prometheus version vendored in Cortex to the latest version.

With the new Prometheus version the LabelValues() call on the Querier interface now has an additional matchers parameter (introduced here).
Unfortunately we won't be able to directly take advantage of this new parameter here, because in order to use it this struct which gets imported from Thanos will also need to be updated:

We also can't update the Prometheus version in Thanos first, because Thanos imports Querier implementations from Cortex, so if we'd update Prometheus in Thanos before updating it in Cortex then the imported Querier implementations wouldn't match the interface defined in Prometheus anymore.
My plan to solve this is to first update the Prometheus version in Cortex, without taking advantage of that new parameter in the LabelValues() call. Then update the Prometheus and the Cortex versions in Thanos. Then make another PR to Cortex which takes advantage of that new parameter.

The main thing I'm uncertain about here is how to deal with the fact that v1.NewAPI (here) now requires the second argument to be a storage.Storage, previously it was a storage.SampleAndChunkQueryable. Since the last argument that we pass into v1.NewAPI() (here) is now hard-coded to false I think it is acceptable to simply add the required methods to errorTranslateQueryable without implementing them, knowing that they will never be called, but I'd definitely be open to suggestions about how to do that in a better way.

@replay replay force-pushed the update_prometheus branch 9 times, most recently from 22e082c to fab788f Compare February 10, 2021 22:45
@replay replay changed the title [WIP] Update prometheus to latest Update prometheus to latest Feb 10, 2021
@replay replay marked this pull request as ready for review February 10, 2021 23:13
@replay replay changed the title Update prometheus to latest Update Prometheus to latest version Feb 10, 2021
@pstibrany
Copy link
Contributor

pstibrany commented Feb 12, 2021

The main thing I'm uncertain about here is how to deal with the fact that v1.NewAPI (here) now requires the second argument to be a storage.Storage, previously it was a storage.SampleAndChunkQueryable. Since the last argument that we pass into v1.NewAPI() (here) is now hard-coded to false I think it is acceptable to simply add the required methods to errorTranslateQueryable without implementing them, knowing that they will never be called, but I'd definitely be open to suggestions about how to do that in a better way.

I would suggest to keep errorTranslateQueryable as is (ie. reverting your change), and introduce new readOnlyStorage type that embeds storage.SampleAndChunkQueryable, and adds additional missing methods from Storage interface. Those missing methods should also return errors where appropriate (esp. Appender part). WDYT?

@replay
Copy link
Contributor Author

replay commented Feb 12, 2021

I would suggest to keep errorTranslateQueryable as is (ie. reverting your change), and introduce new readOnlyStorage type that embeds storage.SampleAndChunkQueryable, and adds additional missing methods from Storage interface. Those missing methods should also return errors where appropriate (esp. Appender part). WDYT?

That sounds better indeed, I'll do that, thx

@replay replay force-pushed the update_prometheus branch 3 times, most recently from 2e29442 to e2c88e7 Compare February 12, 2021 19:21
@replay
Copy link
Contributor Author

replay commented Feb 12, 2021

@pstibrany i updated it, thanks for the suggestion

@codesome
Copy link
Contributor

codesome commented Feb 15, 2021

This might need to go into the next release to include this fix (affects timestamp() function with @ modifier). Nevermind, I see that the 1.7.0 rc does not include the @ modifier at all :) all good here

Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

It is unfortunate that NewAPI takes Storage, which requires us to implement extra methods. I've sent PR prometheus/prometheus#8488 to Prometheus to be able to pass queryable and appendable separately. If it is merged quickly, then I'm fine with taking shortcuts in this PR and just implement bare-minimum (as it is now). However, if prometheus/prometheus#8488 isn't merged, then we should implement "errAppender" to return errors, as current implementation of readOnlyStorage.Appender() returning nil may cause panics. It's also not clear what we should be returning in StartTime, although API doesn't use this method currently.

Apart from that, this PR looks good.

@roidelapluie
Copy link
Contributor

I will merge it on the other side :)

@pstibrany
Copy link
Contributor

Since Prometheus PR 8488 is now merged, let's update Prometheus in this PR.

replay and others added 4 commits February 15, 2021 12:57
Signed-off-by: Mauro Stettler <mauro.stettler@gmail.com>
Signed-off-by: Mauro Stettler <mauro.stettler@gmail.com>
Signed-off-by: Mauro Stettler <mauro.stettler@gmail.com>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
@replay
Copy link
Contributor Author

replay commented Feb 15, 2021

Thx for that Prometheus change @pstibrany . I have update Prometheus in this branch again, and I also rebased onto the latest master.

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.

LGTM, thanks!

@@ -870,7 +871,8 @@ func createLabelNamesRequest(minT, maxT int64, blockIDs []ulid.ULID) (*storepb.L
return req, nil
}

func createLabelValuesRequest(minT, maxT int64, label string, blockIDs []ulid.ULID) (*storepb.LabelValuesRequest, error) {
func createLabelValuesRequest(minT, maxT int64, label string, blockIDs []ulid.ULID, matchers ...*labels.Matcher) (*storepb.LabelValuesRequest, error) {
// TODO(replay): add matchers to LabelValuesRequest once it has that property
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, considering the store-gateway doesn't support it yet.

Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Good job, thank you!

Co-authored-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Mauro Stettler <mauro.stettler@gmail.com>
@pstibrany pstibrany merged commit dfededd into cortexproject:master Feb 15, 2021
@replay replay deleted the update_prometheus branch February 15, 2021 15:54
@bboreham bboreham changed the title Update Prometheus to latest version Update Prometheus; add matchers parameter to LabelValues on ingester Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants