-
Notifications
You must be signed in to change notification settings - Fork 1.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
Vmselect slow query https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5134 #6167
base: cluster
Are you sure you want to change the base?
Conversation
Signed-off-by: root <root@C-5CG324677Z>
@@ -902,6 +956,32 @@ var ( | |||
httpRequestsDuration = tenantmetrics.NewCounterMap(`vm_tenant_select_requests_duration_ms_total`) | |||
) | |||
|
|||
var ( | |||
slowQueries = metrics.NewCounter(`vm_slow_queries_total{path="*"}`) |
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 metric can be removed, since it's the same as sum(vm_slow_queries_total{path!=""})
.
@@ -182,6 +180,61 @@ var ( | |||
}) | |||
) | |||
|
|||
func updateSlowQueryPathCounter(p *httpserver.Path, path string) { |
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 don't think we need a duplicated function to identify the query path, we can increase counters in the original handler.
The code can be like this
var slowQueries *metrics.Counter
if *logSlowQueryDuration > 0 {
actualStartTime := time.Now()
defer func() {
d := time.Since(actualStartTime)
if d >= *logSlowQueryDuration {
...
slowQueries.Inc()
}
}()
}
...
if path == "/admin/tenants" {
tenantsRequests.Inc()
slowQueries = pathSlowTenantsRequests
...
// selectHandler()
switch p.Suffix {
case "prometheus/api/v1/query":
queryRequests.Inc()
slowQueries = pathSlowQuery
httpserver.EnableCORS(w, r)
if err := prometheus.QueryHandler(qt, startTime, at, w, r); err != nil {
queryErrors.Inc()
sendPrometheusError(w, r, err)
return true
}
return true
case "prometheus/api/v1/query_range":
queryRangeRequests.Inc()
slowQueries = pathSlowQueryRange
@@ -234,6 +287,11 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { | |||
return true | |||
} | |||
} | |||
p, err := httpserver.ParsePath(path) |
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 check can't be moved before handlers /internal/resetRollupResultCache
and /admin/tenants
, it requires path to have /{prefix}/{tenantID}/{suffix}
form.
…s/issues/5134
Describe Your Changes
Please provide a brief description of the changes you made. Be as specific as possible to help others understand the purpose and impact of your modifications.
Checklist
The following checks are mandatory: