-
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
Query Frontend: add query instant tripperware for query sharding #5561
Conversation
@@ -133,6 +137,97 @@ func (r *ThanosQueryRangeRequest) String() string { return "" } | |||
// which is not used in thanos. | |||
func (r *ThanosQueryRangeRequest) ProtoMessage() {} | |||
|
|||
type ThanosQueryInstantRequest struct { |
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.
Do we have a way to use the same object for instant and range queries? That way we wouldn't have to duplicate code for these two use cases.
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 prefer to split the two types. Having them in the same struct is okay but we need a flag to maintain whether it is instant query and range query, and check the flag when needed.
Compared to having two types, this is not that clear and require other code, too.
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.
Got it, makes sense 👍
One question, do you think it makes sense to have separate sharding number for query range and query instant? It would mean we change
which is a "breaking change", but we also haven't released the feature yet. |
What about using the same type Config struct {
QueryRangeConfig
LabelsConfig
DownstreamTripperConfig
CortexHandlerConfig *transport.HandlerConfig
CompressResponses bool
CacheCompression string
RequestLoggingDecision string
DownstreamURL string
ForwardHeaders []string
NumShards int
} Now the |
Got it. Let's start with a single flag and we can revisit if a use case comes up. |
After we vendor the cortex package internally, is there a way to import the cortex proto file we vendored? Tried multiple times but didn't find a way to get it working with existing |
Yeah, I think it hasn't been updated. You probably need to add |
Still cannot get it working by adding the Cortex dir to the proto dependency. Wondering what's the future plan on this. |
Could you share the command that fails for you currently? |
Thanks. I figured out a way to compile the Cortex protobuf instead and make changes on it directly. Not sure if it is a acceptable way but I got it working finally. Seems query response parsing and instant query sharding are working properly on my local tests. I will add more tests soon. |
body, _ := ioutil.ReadAll(r.Body) | ||
return nil, httpgrpc.Errorf(r.StatusCode, string(body)) | ||
} | ||
log, ctx := spanlogger.New(ctx, "ParseQueryInstantResponse") //nolint:ineffassign,staticcheck |
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.
SA4006: this value of ctx is never used
Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
074ba82
to
2603a96
Compare
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
2603a96
to
303bc68
Compare
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
Signed-off-by: Ben Ye <ben.ye@bytedance.com>
This is ready for another round of review. @fpetkovski @GiedriusS |
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.
@@ -7,7 +7,7 @@ package cortexpb; | |||
|
|||
option go_package = "cortexpb"; | |||
|
|||
import "github.com/gogo/protobuf/gogoproto/gogo.proto"; | |||
import "gogoproto/gogo.proto"; |
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 wonder if we can do this rewrite in go.mod
or with some sed
magic in the Makefile.
My concern is that the change can be lost the next time we update Cortex.
Yeah, I see your concern. I am not sure about this as well. If needed I can try to avoid modifying the Cortex code. But this causes more code duplication. For example, we need to copy Cortex unexposed functions like merging query stats, etc. |
Even though it's not ideal for syncing up with the upstream Cortex, we'll need to modify the vendored Cortex files. If I'm not mistaken, @GiedriusS also working on a PR that modifies the vendored files. It'll be a half-automated process to upgrade Cortex in Thanos, but I don't see any other options. If someone has a brilliant idea to do this, please let us know :) |
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.
Nice, just one more question from my side. Looking forward to using this!
return nil, err | ||
} | ||
|
||
if r.FormValue(queryv1.MaxSourceResolutionParam) == "auto" { |
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.
Does downsampling apply to instant queries?
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.
Yeah from the instant query API I can see the param is used.
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.
LGTM, it will be a pain to keep Cortex fork up-to-date, though, however it's inevitable and I can't think of a better strategy at the moment. 💪 good work!
Amazing stuff, one of our instant queries went from 36s to 8s. |
Whoops, I didn't expect the PR got merged so quickly. I haven't added some unit tests and changelog, too. I will add them in follow up prs. One important thing I want to make sure is to have PromQL compatibility test for Thanos Query behind the query frontend to make sure no regression. Since the pr is already large I will do it in another pr, too. |
…nos-io#5561) * add query instant tripperware for query sharding Signed-off-by: Ben Ye <ben.ye@bytedance.com> * fix lint Signed-off-by: Ben Ye <ben.ye@bytedance.com> * working version for instant query sharding Signed-off-by: Ben Ye <ben.ye@bytedance.com> * tidy up Signed-off-by: Ben Ye <ben.ye@bytedance.com> * lint Signed-off-by: Ben Ye <ben.ye@bytedance.com> * fix unit test Signed-off-by: Ben Ye <ben.ye@bytedance.com> * remove ioutil Signed-off-by: Ben Ye <ben.ye@bytedance.com> * fix E2E test Signed-off-by: Ben Ye <ben.ye@bytedance.com> * add e2e test for instant query sharding Signed-off-by: Ben Ye <ben.ye@bytedance.com> Signed-off-by: Ben Ye <ben.ye@bytedance.com>
Signed-off-by: Ben Ye ben.ye@bytedance.com
Changes
This pr adds a simple tripperware for sharding instant queries.
Verification