-
Notifications
You must be signed in to change notification settings - Fork 793
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 new query stats metrics to track prometheus querystats #6228
base: master
Are you sure you want to change the base?
Add new query stats metrics to track prometheus querystats #6228
Conversation
0a571de
to
d4ddae7
Compare
pkg/frontend/transport/handler.go
Outdated
|
||
h.queryPeakSamples = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ | ||
Name: "cortex_query_peak_samples_total", | ||
Help: "Highest count of samples considered to execute a query.", |
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.
Can you please explain the usecase of tracking peak samples using a counter 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.
I think like promQL: sum by (user) (irate(cortex_query_peak_samples_total[5m]))
, the cortex user can track the rate of how many samples are loaded in memory for each tenant's overall queries.
One usecase is:
- The cortex user can track query memory usage (used by loaded samples) for each tenant and turn promQL to reduce query memory usage.
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.
OK. For a counter metric I feel it is more useful to just track total samples, not peak samples.
Would it be more useful to use native histogram instead?
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.
Yes, I think the histogram is the best.
pkg/frontend/transport/handler.go
Outdated
@@ -122,6 +124,16 @@ func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logge | |||
Help: "Number of samples fetched to execute a query.", | |||
}, []string{"user"}) | |||
|
|||
h.queryTotalQueryableSamples = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{ | |||
Name: "cortex_query_total_queryable_samples_total", | |||
Help: "Number of total queryable samples to execute a query.", |
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 feel queryable samples is a bit confusing.
What about cortex_query_samples_processed_total
or cortex_query_samples_scanned_total
?
You can add a comment to reference it to https://github.com/prometheus/prometheus/blob/main/util/stats/query_stats.go#L237
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.
For me, cortex_query_samples_processed_total
is more good. Thank you!
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.
How about changing the variable name queryTotalQueryableSamples
to queryProcessedSamples
and querySamples
to queryFetchedSamples
?
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 we can keep queryTotalQueryableSamples
as it is clear that it refers to Total Samples
.
Makes sense to rename querySamples
to queryFetchedSamples
.
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 fixed it.
afea4c7
to
1e37e70
Compare
@yeya24 |
1e37e70
to
0cfa84b
Compare
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
0cfa84b
to
797b6ee
Compare
What this PR does:
Add new query stats metrics
cortex_query_total_queryable_samples_total
andcortex_query_peak_samples
.These track
TotalQueryableSamples
andPeakSamples
for each in https://github.com/prometheus/prometheus/blob/main/util/stats/query_stats.goWhich issue(s) this PR fixes:
Fixes
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]