-
Notifications
You must be signed in to change notification settings - Fork 806
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 for tracking push requests size #6384
Open
SungJin1212
wants to merge
1
commit into
cortexproject:master
Choose a base branch
from
SungJin1212:Add-histogram-for-tracking-various-push-size
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,9 @@ type Distributor struct { | |
|
||
asyncExecutor util.AsyncExecutor | ||
|
||
// metrics passed to push handler | ||
PushHandlerMetrics *PushHandlerMetrics | ||
|
||
// Map to track label sets from user. | ||
labelSetTracker *labelSetTracker | ||
} | ||
|
@@ -180,6 +183,32 @@ type Config struct { | |
OTLPConfig OTLPConfig `yaml:"otlp"` | ||
} | ||
|
||
type PushHandlerMetrics struct { | ||
pushRequestSizeBytes *prometheus.HistogramVec | ||
} | ||
|
||
func NewPushHandlerMetrics(reg prometheus.Registerer) *PushHandlerMetrics { | ||
return &PushHandlerMetrics{ | ||
pushRequestSizeBytes: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: "cortex_distributor_push_requests_uncompressed_size_bytes", | ||
Help: "Histogram of push request's uncompressed size in bytes", | ||
NativeHistogramBucketFactor: 1.1, | ||
NativeHistogramMinResetDuration: 1 * time.Hour, | ||
NativeHistogramMaxBucketNumber: 100, | ||
}, []string{"user", "format"}), | ||
} | ||
} | ||
|
||
func (m *PushHandlerMetrics) ObservePushRequestSize(user, format string, size float64) { | ||
if m != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this check? |
||
m.pushRequestSizeBytes.WithLabelValues(user, format).Observe(size) | ||
} | ||
} | ||
|
||
func (m *PushHandlerMetrics) deleteUserMetrics(user string) { | ||
m.pushRequestSizeBytes.DeleteLabelValues(user) | ||
} | ||
|
||
type InstanceLimits struct { | ||
MaxIngestionRate float64 `yaml:"max_ingestion_rate"` | ||
MaxInflightPushRequests int `yaml:"max_inflight_push_requests"` | ||
|
@@ -384,8 +413,9 @@ func New(cfg Config, clientConfig ingester_client.Config, limits *validation.Ove | |
Help: "Unix timestamp of latest received sample per user.", | ||
}, []string{"user"}), | ||
|
||
validateMetrics: validation.NewValidateMetrics(reg), | ||
asyncExecutor: util.NewNoOpExecutor(), | ||
validateMetrics: validation.NewValidateMetrics(reg), | ||
PushHandlerMetrics: NewPushHandlerMetrics(reg), | ||
asyncExecutor: util.NewNoOpExecutor(), | ||
} | ||
|
||
d.labelSetTracker = newLabelSetTracker(d.receivedSamplesPerLabelSet) | ||
|
@@ -501,6 +531,8 @@ func (d *Distributor) cleanupInactiveUser(userID string) { | |
d.nonHASamples.DeleteLabelValues(userID) | ||
d.latestSeenSampleTimestampPerUser.DeleteLabelValues(userID) | ||
|
||
d.PushHandlerMetrics.deleteUserMetrics(userID) | ||
|
||
if err := util.DeleteMatchingLabels(d.dedupedSamples, map[string]string{"user": userID}); err != nil { | ||
level.Warn(d.log).Log("msg", "failed to remove cortex_distributor_deduped_samples_total metric for user", "user", userID, "err", err) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 really need the
format
parameter here. Why would we need different limits for different formats? Do we plan to have a new limit for RW 2.0?I feel we should consolidate the request size limit into one #6333.
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 have no plan to something limit for PRW 2.0. It could be that we can add some limits. But, I thought different formats (prw1, prw2, and otlp) would have different body sizes.
So, I attached the
format
label so that the user can configure limit configs for different formats.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.
If we want to track different formats then for the same reason we need to differentiate compression formats as well as they have different sizes. OTLP has protobuf and JSON then we also need to differentiate that.
To simplify things I think it is good enough to use a single size limit and metric
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.
It makes sense.
Then, de-attach
format
and make 'cortex_distributor_push_requests_uncompressed_size_bytestrack the uncompressed size of all of the formats. Next step is to delete
distributor.otlp-max-recv-msg-size` flags.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.
Let's hear from other maintainers...
@friedrichg @danielblando @alanprot @CharlieTLe ?