-
Notifications
You must be signed in to change notification settings - Fork 784
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
Add PushOnlyIngester gRPC service; Disable label name validation #3736
Add PushOnlyIngester gRPC service; Disable label name validation #3736
Conversation
406a543
to
7ba6e79
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.
LGTM, modulo linting fix
pkg/distributor/distributor_test.go
Outdated
@@ -4,6 +4,7 @@ import ( | |||
"bytes" | |||
"context" | |||
"fmt" | |||
"google.golang.org/grpc/status" |
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.
This import needs to be separate from the standard library imports. We run rather strict linter settings for the project and this is triggering the CI failure.
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.
ahh, good to know, thanks!
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.
just a bit more detail about the linting: https://cortexmetrics.io/docs/contributing/#formatting
What is the usecase here? I expect promql not to work without proper metric names. |
I also quote @pstibrany
|
As far as I understand it, the use case here is to add a support for storing a non-Prometheus monitoring data into Cortex. This would be achieved by 1) having a proxy for incoming data that would sit in front of distributor, and call Push on distributor via gRPC with this new flag set to true (skip validation). 2) On query time, there would be a special querier that doesn't use PromQL at all, but use Cortex' store-gateway to fetch required data. Additional support in Cortex needed to make this work is pretty small: disable label validation (this PR), and expose distributor push via gRPC. I think this falls well within "low-hanging fruit to make some use-cases easier". |
pkg/ingester/client/cortex.proto
Outdated
@@ -33,6 +33,7 @@ message WriteRequest { | |||
} | |||
SourceEnum Source = 2; | |||
repeated MetricMetadata metadata = 3 [(gogoproto.nullable) = true]; | |||
bool skip_label_name_validation = 4; |
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'm wondering if we should use google.protobuf.Any hints
approach here. Strictly speaking this isn't supported by Ingester service, so it doesn't belong here. But Distributor implements the same method. (When we expose Distributor via gRPC, I expect it will reuse the same Push
method, with cortex.WriteRequest
and cortex.WriteResponse
)
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.
We need to keep WriteRequest
compatible with Prometheus one. If we use the field number 4
, it's very likely it will clash next time Prometheus remote write adds a new field. To fix this, we could use a very high field number (eg. 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.
@pstibrany is the google.protobuf.Any hints
approach like the options
field in the rules proto (
cortex/pkg/ruler/rules/rules.proto
Line 29 in d625141
repeated google.protobuf.Any options = 9; |
@@ -366,9 +366,9 @@ func (d *Distributor) checkSample(ctx context.Context, userID, cluster, replica | |||
// Validates a single series from a write request. Will remove labels if | |||
// any are configured to be dropped for the user ID. | |||
// Returns the validated series with it's labels/samples, and any error. | |||
func (d *Distributor) validateSeries(ts ingester_client.PreallocTimeseries, userID string) (client.PreallocTimeseries, error) { | |||
func (d *Distributor) validateSeries(ts ingester_client.PreallocTimeseries, userID string, skipLabelNameValidation bool) (ingester_client.PreallocTimeseries, error) { |
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 catch! I've sent separate PR #3738 to fix double-import of ingester_client
package in this file.
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.
We've just merged #3738. Could you rebase master
, please?
pkg/ingester/client/cortex.proto
Outdated
@@ -33,6 +33,7 @@ message WriteRequest { | |||
} | |||
SourceEnum Source = 2; | |||
repeated MetricMetadata metadata = 3 [(gogoproto.nullable) = true]; | |||
bool skip_label_name_validation = 4; |
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.
We need to keep WriteRequest
compatible with Prometheus one. If we use the field number 4
, it's very likely it will clash next time Prometheus remote write adds a new field. To fix this, we could use a very high field number (eg. 1000
).
@@ -366,9 +366,9 @@ func (d *Distributor) checkSample(ctx context.Context, userID, cluster, replica | |||
// Validates a single series from a write request. Will remove labels if | |||
// any are configured to be dropped for the user ID. | |||
// Returns the validated series with it's labels/samples, and any error. | |||
func (d *Distributor) validateSeries(ts ingester_client.PreallocTimeseries, userID string) (client.PreallocTimeseries, error) { | |||
func (d *Distributor) validateSeries(ts ingester_client.PreallocTimeseries, userID string, skipLabelNameValidation bool) (ingester_client.PreallocTimeseries, error) { |
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.
We've just merged #3738. Could you rebase master
, please?
@@ -495,7 +495,8 @@ func (d *Distributor) Push(ctx context.Context, req *client.WriteRequest) (*clie | |||
return nil, err | |||
} | |||
|
|||
validatedSeries, err := d.validateSeries(ts, userID) | |||
skipLabelNameValidation := d.cfg.SkipLabelNameValidation || req.GetSkipLabelNameValidation() |
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.
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.
You're right, we won't need the SkipLabelNameValidation
in the config struct anymore.
Would it be fine for you if we remove that flag from the Distributor config in a separate PR after this one has been merged? That would help because otherwise merging this PR is going to break the down-stream CI tests of projects relying on the Distributor config flag, if we remove it in a separate PR we can first switch the down-stream users to rely on this new per-request flag and only after that we remove the Distributor config flag.
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'm fine if you will do it in a separate PR.
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
7ba6e79
to
fe982d5
Compare
* distributor needs to be registered with grpc server so that other services have this new validation bypass option when talking to distributor directly * util used to translate http -> grpc always sets SkipLabelNameValidation to false to force validation on all http requests as only gRPC requests should be allowed to bypass this validation Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
fe982d5
to
c19420c
Compare
Thanks everyone, just pushed up a commit that hopefully resolves above mentioned issues.
|
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
(trevor, note that I'm not a maintainer, so my approval doesn't count towards the requirement of 2
to merge)
haha, @replay appreciate the support nonetheless! |
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.
(Nit: it seems little strange that "cortex.Distributor" gRPC service is defined in ingester package)
@pstibrany how would you feel about renaming the new service to |
I don’t have a strong preference, and also I’m fine with keeping it as is. |
Signed-off-by: Trevor Whitney <trevorjwhitney@gmail.com>
I went ahead with the rename of |
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! Please remind to open a PR to remove the "skip label name validation" from config, since you mentioned you don't need to anymore.
What this PR does:
This PR enables users who want to store non-conventional prometheus data in cortex by exposing the ability to disable label name validation via a request parameter. This option is currently available to in the distributor config, but that requires you to run a whole separate distributor to handle requests for this type. By exposing this option through the
WriteRequest
, a single distributor can handle both payload types.Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]