mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
app/vmselect: rename promql.WriteActiveQueries() to promql.ActiveQueriesHandler()
This makes it more consistent with the rest of handlers inside app/vmselect/main.go
This is a follow-up for 6a96fd8ed5
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4598
This commit is contained in:
parent
992c300ce9
commit
0cbe5ccb4a
@ -269,7 +269,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
if path == "/api/v1/status/active_queries" {
|
if path == "/api/v1/status/active_queries" {
|
||||||
globalStatusActiveQueriesRequests.Inc()
|
globalStatusActiveQueriesRequests.Inc()
|
||||||
httpserver.EnableCORS(w, r)
|
httpserver.EnableCORS(w, r)
|
||||||
promql.WriteActiveQueries(w, r)
|
promql.ActiveQueriesHandler(nil, w, r)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if path == "/admin/tenants" {
|
if path == "/admin/tenants" {
|
||||||
@ -507,7 +507,7 @@ func selectHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseW
|
|||||||
case "prometheus/api/v1/status/active_queries":
|
case "prometheus/api/v1/status/active_queries":
|
||||||
statusActiveQueriesRequests.Inc()
|
statusActiveQueriesRequests.Inc()
|
||||||
httpserver.EnableCORS(w, r)
|
httpserver.EnableCORS(w, r)
|
||||||
promql.WriteActiveQueriesForTenant(at, w, r)
|
promql.ActiveQueriesHandler(at, w, r)
|
||||||
return true
|
return true
|
||||||
case "prometheus/api/v1/status/top_queries":
|
case "prometheus/api/v1/status/top_queries":
|
||||||
topQueriesRequests.Inc()
|
topQueriesRequests.Inc()
|
||||||
|
@ -11,21 +11,23 @@ import (
|
|||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/auth"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteActiveQueriesForTenant writes active queries for the given (accountID, projectID) to w.
|
// ActiveQueriesHandler returns response to /api/v1/status/active_queries
|
||||||
func WriteActiveQueriesForTenant(at *auth.Token, w http.ResponseWriter, r *http.Request) {
|
//
|
||||||
|
// It writes a JSON with active queries to w.
|
||||||
|
//
|
||||||
|
// If at is nil, then all the active queries across all the tenants are written.
|
||||||
|
func ActiveQueriesHandler(at *auth.Token, w http.ResponseWriter, r *http.Request) {
|
||||||
aqes := activeQueriesV.GetAll()
|
aqes := activeQueriesV.GetAll()
|
||||||
var dst []activeQueryEntry
|
if at != nil {
|
||||||
|
// Filter out queries, which do not belong to at.
|
||||||
|
dst := aqes[:0]
|
||||||
for _, aqe := range aqes {
|
for _, aqe := range aqes {
|
||||||
if aqe.accountID == at.AccountID && aqe.projectID == at.ProjectID {
|
if aqe.accountID == at.AccountID && aqe.projectID == at.ProjectID {
|
||||||
dst = append(dst, aqe)
|
dst = append(dst, aqe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeActiveQueries(w, dst)
|
aqes = dst
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteActiveQueries writes active queries to w.
|
|
||||||
func WriteActiveQueries(w http.ResponseWriter, r *http.Request) {
|
|
||||||
aqes := activeQueriesV.GetAll()
|
|
||||||
writeActiveQueries(w, aqes)
|
writeActiveQueries(w, aqes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user