-
Notifications
You must be signed in to change notification settings - Fork 822
Add native histogram max sample size limit validation #6834
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 native histogram max sample size limit validation #6834
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.
Overall looks good. One nit.
pkg/util/validation/limits.go
Outdated
MaxLabelValueLength int `yaml:"max_label_value_length" json:"max_label_value_length"` | ||
MaxLabelNamesPerSeries int `yaml:"max_label_names_per_series" json:"max_label_names_per_series"` | ||
MaxLabelsSizeBytes int `yaml:"max_labels_size_bytes" json:"max_labels_size_bytes"` | ||
MaxNativeHistogramsSampleSizeBytes int `yaml:"max_native_histograms_sample_size_bytes" json:"max_native_histograms_sample_size_bytes"` |
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.
nit: MaxNativeHistogramSampleSizeBytes
This is for a single sample. Not like the labels limit which is for all the labels.
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. Updated.
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. Just some nits. Rest LGTM
pkg/util/validation/errors.go
Outdated
@@ -262,6 +262,26 @@ func (e *nativeHistogramSchemaInvalidError) Error() string { | |||
return fmt.Sprintf("invalid native histogram schema %d for metric: %.200q. supported schema from %d to %d", e.receivedSchema, formatLabelSet(e.series), histogram.ExponentialSchemaMin, histogram.ExponentialSchemaMax) | |||
} | |||
|
|||
// nativeHistogramSchemaInvalidError is a ValidationError implementation for samples with native histogram | |||
// exceeding the valid schema range. |
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.
Need to update the comment. Not nativeHistogramSchemaInvalidError
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. Updated.
pkg/util/validation/validate.go
Outdated
@@ -339,6 +340,13 @@ func ValidateMetadata(validateMetrics *ValidateMetrics, cfg *Limits, userID stri | |||
|
|||
func ValidateNativeHistogram(validateMetrics *ValidateMetrics, limits *Limits, userID string, ls []cortexpb.LabelAdapter, histogramSample cortexpb.Histogram) (cortexpb.Histogram, error) { | |||
|
|||
// sample size validation for native histogram | |||
nhSampleSize := histogramSample.Size() |
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.
Nit: we can only calculate the sample size if the limit is > 0.
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. Updated.
Signed-off-by: Paurush Garg <[email protected]>
ec63c2b
to
e33587b
Compare
Signed-off-by: Paurush Garg <[email protected]>
What this PR does:
Add native histogram max sample size bytes limit validation.
This is added b/c native histogram can have infinite buckets for a given schema increasing the size of a nh sample. Size of a NH sample can also grow due to other factors like Spans. Although max_bucket_count limit reduces resolution of NH samples, but this limit is added to discard samples if the sample size is excessive and can load Distributors.
This limit is not added as per-user override.
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]