-
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 <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Add custom lookback delta support in query grpc api Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
Signed-off-by: Oron Sharabi <oron.sh@coralogix.com>
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 <ben.ye@bytedance.com>
* cut 0.28.0-rc.0 Signed-off-by: Ben Ye <ben.ye@bytedance.com> * address review comments Signed-off-by: Ben Ye <ben.ye@bytedance.com> * mention experimental/hidden features Signed-off-by: Ben Ye <ben.ye@bytedance.com> * include #5607 in changelog Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com>
) * Update prometheus version to v0.38.0 Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Add custom lookbackDelta from request support for query api Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Add change to CHANGELOG Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Fix tests Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Fix lints Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Replace engineFactory with lookbackDeltaFactory Add custom lookback delta support in query grpc api Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Replace TestEngineFactory with TestLookbackDeltaFactory test Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Run formatter Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Fix manager_test.go Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Remove engineFactory and adjust comment Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Go fmt query.go Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Fix test and lints Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Remove self-assignment of engineOpts.ActiveQueryTracker Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Fix query.proto backwards compatibility Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Fix comment indentation Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> * Multiply maxResolution by 1000 in grpc api Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> Signed-off-by: Oron Sharabi <oron.sh@coralogix.com> Signed-off-by: Prakul Jain <prakul.jain@udaan.com>
* Cut 0.28.0-rc.0 (#5632) * cut 0.28.0-rc.0 Signed-off-by: Ben Ye <ben.ye@bytedance.com> * address review comments Signed-off-by: Ben Ye <ben.ye@bytedance.com> * mention experimental/hidden features Signed-off-by: Ben Ye <ben.ye@bytedance.com> * include #5607 in changelog Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com> * cut v0.28.0 (#5647) Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com> * 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 <sotiris.nanopoulos@reddit.com> * Adds changelog entry Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Ben Ye <benye@amazon.com> * update changelog and version Signed-off-by: Ben Ye <benye@amazon.com> add line Signed-off-by: Ben Ye <benye@amazon.com> * update version to 0.28.1 Signed-off-by: Ben Ye <benye@amazon.com> Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Ben Ye <benye@amazon.com> Co-authored-by: Sotiris Nanopoulos <sonanopo@microsoft.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Ben Ye <benye@amazon.com> Co-authored-by: Ben Ye <ben.ye@bytedance.com> Co-authored-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
* Cut 0.28.0-rc.0 (thanos-io#5632) * cut 0.28.0-rc.0 Signed-off-by: Ben Ye <ben.ye@bytedance.com> * address review comments Signed-off-by: Ben Ye <ben.ye@bytedance.com> * mention experimental/hidden features Signed-off-by: Ben Ye <ben.ye@bytedance.com> * include thanos-io#5607 in changelog Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com> * cut v0.28.0 (thanos-io#5647) Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com> * 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 <sotiris.nanopoulos@reddit.com> * Adds changelog entry Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Ben Ye <benye@amazon.com> * update changelog and version Signed-off-by: Ben Ye <benye@amazon.com> add line Signed-off-by: Ben Ye <benye@amazon.com> * update version to 0.28.1 Signed-off-by: Ben Ye <benye@amazon.com> Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Ben Ye <benye@amazon.com> Co-authored-by: Sotiris Nanopoulos <sonanopo@microsoft.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com> Signed-off-by: Ben Ye <benye@amazon.com> Co-authored-by: Ben Ye <ben.ye@bytedance.com> Co-authored-by: Sotiris Nanopoulos <sonanopo@microsoft.com> Signed-off-by: utukj <utukphd@gmail.com>
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