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

`storage.Querier` interface not fitting for remote implementations #3220

Closed
juliusv opened this Issue Sep 25, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@juliusv
Copy link
Member

juliusv commented Sep 25, 2017

The storage.Querier definition at:

https://github.com/prometheus/prometheus/blob/dev-2.0/storage/interface.go#L43-L53

...is not great for remote querier implementations. Remote querier implementations will want to eager-load all series data upon Select(), but some uses of Select() are only interested in the series metadata (such as /api/v1/series). In that case, eager-loading all the sample data would be very wasteful. Those users would need a way to tell the querier their future intentions or have a separate interface method that only provides metadata.

The concrete use case where this is hitting me right now is porting Cortex to Prometheus 2.0 packages. We reuse the Prometheus api/v1 package there to give us the Prometheus web API, but the API cannot tell the querier that we pass in whether it will only want to load series metadata or full sample data.

Would adding a separate method to storage.Querier for explicit metadata-only selection make sense? Or some other form of parametrization in Select()?

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Sep 25, 2017

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Oct 2, 2017

I think it's the right interface for the domain problem it is trying to solve. It can obviously be unfitting in the case you are describing though.

Just extending/mutating the core interface seems wrong. I would push this out into the instantiation of the storage.Querier, e.g. myRemoteStorage.MetadataQuerier() and myRemoteStorage.FullQuerier(). The former could just error when the sample data tries to be touched, or do it inefficiently anyway – implementers choice really.

What would need to be adapted then is the API package so that it doesn't take a full storage as a dependency but just the most basic methods to retrieve the relevant data. The amount of fan-in of entire components into the web handler is way to much anyway.

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Oct 2, 2017

Sounds good as well. Even better, NewAPI() already takes both a promql.Engine and a local.Storage, which will already allow me to do this without modifying the API package (by constructing the promql.Engine from a different querier).

So I'll take that approach. Thanks!

@juliusv juliusv closed this Oct 2, 2017

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.