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

Filter instant queries and shard them. #3984

Merged
merged 29 commits into from
Jul 23, 2021

Conversation

jeschkies
Copy link
Contributor

@jeschkies jeschkies commented Jul 12, 2021

What this PR does / why we need it:
This patch also enables query sharding for instant queries in addition to the range query sharding.

Checklist

  • Documentation added
  • Tests updated

pkg/querier/queryrange/codec.go Show resolved Hide resolved
pkg/querier/queryrange/downstreamer.go Outdated Show resolved Hide resolved
Comment on lines 108 to 116
var params logql.Params
var path string
switch r.(type) {
case *LokiRequest:
params = paramsFromRequest(r)
path = r.(*LokiRequest).GetPath()
case *LokiInstantRequest:
params = paramsFromInstantRequest(r)
path = r.(*LokiInstantRequest).GetPath()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish LokiRequest and LokiInstantRequest would simply implement Params. It's almost the same.

pkg/querier/queryrange/querysharding.go Show resolved Hide resolved
@jeschkies jeschkies marked this pull request as ready for review July 14, 2021 10:15
@jeschkies jeschkies requested a review from a team as a code owner July 19, 2021 13:01
Co-authored-by: Cyril Tovena <cyril.tovena@gmail.com>
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

Making great progress through some very complex code. Left some comments/suggestions - I think this isn't far from being merged :)

@@ -75,6 +75,48 @@ func (r *LokiRequest) LogToSpan(sp opentracing.Span) {

func (*LokiRequest) GetCachingOptions() (res queryrange.CachingOptions) { return }

func (r *LokiInstantRequest) GetStep() int64 {
Copy link
Member

Choose a reason for hiding this comment

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

nit for later: we can probably serialize a lot of these methods into an embedded struct for reuse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean?

pkg/querier/queryrange/codec.go Outdated Show resolved Hide resolved
pkg/querier/queryrange/downstreamer.go Outdated Show resolved Hide resolved
pkg/querier/queryrange/roundtrip.go Outdated Show resolved Hide resolved
@@ -426,3 +448,45 @@ func NewMetricTripperware(
return next
}, c, nil
}

// NewInstantMetricTripperware creates a new frontend tripperware responsible for handling metric queries
func NewInstantMetricTripperware(
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use the ResultsCacheMiddleware like we do in the metric tripperware?

pkg/querier/queryrange/roundtrip.go Outdated Show resolved Hide resolved
pkg/querier/queryrange/roundtrip_test.go Outdated Show resolved Hide resolved
@jeschkies
Copy link
Contributor Author

Alright. It's working! We've got a speed up of almost one magnitude!

@jeschkies jeschkies requested review from cyriltovena and owen-d July 22, 2021 13:36
Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

one nit, but LGTM. Nice work!

pkg/querier/queryrange/roundtrip_test.go Outdated Show resolved Hide resolved
@owen-d owen-d merged commit 17f4a73 into grafana:main Jul 23, 2021
@jeschkies jeschkies deleted the karsten/instant-query-sharding branch July 23, 2021 12:39
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.

3 participants