-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support custom lookback delta from request for query api #5607
Conversation
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.
Thanks for this! It's probably a good idea to also remove the creation of multiple engines in the same go because with only this change it would still be a bit awkward to change this parameter in multiple places. We could simply move the logic from that function to here. What do you think?
Yes so if I got it right, you suggest to calculate the "dynamic lookback delta" according to |
@GiedriusS how do you feel about replacing func LookbackDeltaFactory(
eo promql.EngineOpts,
dynamicLookbackDelta bool
) func(int64) time.Duration {
resolutions := []int64{downsample.ResLevel0}
if dynamicLookbackDelta {
resolutions = []int64{downsample.ResLevel0, downsample.ResLevel1, downsample.ResLevel2}
}
var (
lds = make([]time.Duration, len(resolutions))
ld = eo.LookbackDelta.Milliseconds()
)
lookbackDelta := eo.LookbackDelta
for i, r := range resolutions {
if ld < r {
lookbackDelta = time.Duration(r) * time.Millisecond
}
lds[i] = lookbackDelta
}
return func(maxSourceResolutionMillis int64) time.Duration {
for i := len(resolutions) - 1; i >= 1; i-- {
left := resolutions[i-1]
if resolutions[i-1] < ld {
left = ld
}
if left < maxSourceResolutionMillis {
return lds[i]
}
}
return lds[0]
}
} so we can pass it to |
@@ -249,6 +250,20 @@ func (qapi *QueryAPI) parseStoreDebugMatchersParam(r *http.Request) (storeMatche | |||
return storeMatchers, nil | |||
} | |||
|
|||
func (qapi *QueryAPI) parseLookbackDeltaParam(r *http.Request) (time.Duration, *api.ApiError) { |
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.
Could we also add the same parameter to the gRPC query API?
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.
Sure I'll add it
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.
done
Something like that should work 👍 could you please add unit tests for a such function to ensure that it works properly? Finally, we will be able to get rid of multiple engines. This also means that concurrency limits will finally be enforced properly because previously we had three engines so technically the actual limit was 3 times higher. |
Sure @GiedriusS, I'll add the unit tests :) |
8817607
to
f1150f6
Compare
pkg/api/query/grpc.go
Outdated
@@ -60,6 +62,11 @@ func (g *GRPCAPI) Query(request *querypb.QueryRequest, server querypb.Query_Quer | |||
maxResolution = g.defaultMaxResolutionSeconds.Milliseconds() / 1000 | |||
} | |||
|
|||
lookbackDelta := g.lookbackDeltaCreate(maxResolution) |
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.
Shouldn't it be
lookbackDelta := g.lookbackDeltaCreate(maxResolution * 1000)
since it's lookbackDeltaCreate
(and old queryEngine(..)
) suppose to receive parameter in millis
?
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.
That's probably correct but it's the caller's responsibility to pass the proper data and I think the gRPC is unused at the moment. So, I think we should multiply it by 1000. @fpetkovski maybe you know the answer?
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 I made a mistake to use seconds in the gRPC API when the HTTP one uses millis. Because of this, I also think we should multiply by 1000.
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.
done @fpetkovski @GiedriusS 🙏
@GiedriusS @fpetkovski I implemented the requests:
|
2175e66
to
60a9300
Compare
60a9300
to
b18cc44
Compare
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.
Solid work, just one unsolved conversation in the gRPC API. 💪
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Add custom lookback delta support in query grpc api Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
Signed-off-by: Oron Sharabi <[email protected]>
5d926e2
to
d65fb64
Compare
Please use merge commits in the future to update your branch instead of rebasing since the latter recreates commits with new commit IDs and then the reviewers have to look through everything again. |
Awesome work plus good cleanup! 💪 thank you. |
Signed-off-by: Ben Ye <[email protected]>
* cut 0.28.0-rc.0 Signed-off-by: Ben Ye <[email protected]> * address review comments Signed-off-by: Ben Ye <[email protected]> * mention experimental/hidden features Signed-off-by: Ben Ye <[email protected]> * include #5607 in changelog Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Ben Ye <[email protected]>
) * Update prometheus version to v0.38.0 Signed-off-by: Oron Sharabi <[email protected]> * Add custom lookbackDelta from request support for query api Signed-off-by: Oron Sharabi <[email protected]> * Add change to CHANGELOG Signed-off-by: Oron Sharabi <[email protected]> * Fix tests Signed-off-by: Oron Sharabi <[email protected]> * Fix lints Signed-off-by: Oron Sharabi <[email protected]> * Replace engineFactory with lookbackDeltaFactory Add custom lookback delta support in query grpc api Signed-off-by: Oron Sharabi <[email protected]> * Replace TestEngineFactory with TestLookbackDeltaFactory test Signed-off-by: Oron Sharabi <[email protected]> * Run formatter Signed-off-by: Oron Sharabi <[email protected]> * Fix manager_test.go Signed-off-by: Oron Sharabi <[email protected]> * Remove engineFactory and adjust comment Signed-off-by: Oron Sharabi <[email protected]> * Go fmt query.go Signed-off-by: Oron Sharabi <[email protected]> * Fix test and lints Signed-off-by: Oron Sharabi <[email protected]> * Remove self-assignment of engineOpts.ActiveQueryTracker Signed-off-by: Oron Sharabi <[email protected]> * Fix query.proto backwards compatibility Signed-off-by: Oron Sharabi <[email protected]> * Fix comment indentation Signed-off-by: Oron Sharabi <[email protected]> * Multiply maxResolution by 1000 in grpc api Signed-off-by: Oron Sharabi <[email protected]> Signed-off-by: Oron Sharabi <[email protected]> Signed-off-by: Prakul Jain <[email protected]>
* Cut 0.28.0-rc.0 (#5632) * cut 0.28.0-rc.0 Signed-off-by: Ben Ye <[email protected]> * address review comments Signed-off-by: Ben Ye <[email protected]> * mention experimental/hidden features Signed-off-by: Ben Ye <[email protected]> * include #5607 in changelog Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Ben Ye <[email protected]> * cut v0.28.0 (#5647) Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Ben Ye <[email protected]> * Cut 0.28.1 (#5757) * Updates minio-go to v7.0.37 from v7.0.32 (#5702) * Updates minio-go to v7.0.37 from v7.0.32 fixes #5701 Changelog: minio/minio-go@v7.0.32...v7.0.37 Signed-off-by: Sotiris Nanopoulos <[email protected]> * Adds changelog entry Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> * update changelog and version Signed-off-by: Ben Ye <[email protected]> add line Signed-off-by: Ben Ye <[email protected]> * update version to 0.28.1 Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> Co-authored-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> Co-authored-by: Ben Ye <[email protected]> Co-authored-by: Sotiris Nanopoulos <[email protected]>
* Cut 0.28.0-rc.0 (thanos-io#5632) * cut 0.28.0-rc.0 Signed-off-by: Ben Ye <[email protected]> * address review comments Signed-off-by: Ben Ye <[email protected]> * mention experimental/hidden features Signed-off-by: Ben Ye <[email protected]> * include thanos-io#5607 in changelog Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Ben Ye <[email protected]> * cut v0.28.0 (thanos-io#5647) Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Ben Ye <[email protected]> * Cut 0.28.1 (thanos-io#5757) * Updates minio-go to v7.0.37 from v7.0.32 (thanos-io#5702) * Updates minio-go to v7.0.37 from v7.0.32 fixes thanos-io#5701 Changelog: minio/minio-go@v7.0.32...v7.0.37 Signed-off-by: Sotiris Nanopoulos <[email protected]> * Adds changelog entry Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> * update changelog and version Signed-off-by: Ben Ye <[email protected]> add line Signed-off-by: Ben Ye <[email protected]> * update version to 0.28.1 Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> Co-authored-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> Signed-off-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: Ben Ye <[email protected]> Co-authored-by: Ben Ye <[email protected]> Co-authored-by: Sotiris Nanopoulos <[email protected]> Signed-off-by: utukj <[email protected]>
Changes
engineFactory
withlookbackDeltaFactory
, getting rid of multiple engines.As Thanos supports multi tenancy, we would like to have a custom lookback delta for requests per tenant.
As each tenant can have its own scrape interval and requirements.
Prometheus just added support for it recently:
prometheus/prometheus#9946
Verification