Skip to content

Add a user label to the query_frontend_queue_length metric #2939

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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* [CHANGE] Metric `cortex_overrides_last_reload_successful` has been renamed to `cortex_runtime_config_last_reload_successful`. #2874
* [CHANGE] HipChat support has been removed from the alertmanager (because removed from the Prometheus upstream too). #2902
* [CHANGE] Add constant label `name` to metric `cortex_cache_request_duration_seconds`. #2903
* [CHANGE] Add `user` label to metric `cortex_query_frontend_queue_length`. #2939
* [FEATURE] Introduced `ruler.for-outage-tolerance`, Max time to tolerate outage for restoring "for" state of alert. #2783
* [FEATURE] Introduced `ruler.for-grace-period`, Minimum duration between alert and restored "for" state. This is maintained only for alerts with configured "for" time greater than grace period. #2783
* [FEATURE] Introduced `ruler.resend-delay`, Minimum amount of time to wait before resending an alert to Alertmanager. #2783
Expand Down
8 changes: 4 additions & 4 deletions pkg/querier/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Frontend struct {

// Metrics.
queueDuration prometheus.Histogram
queueLength prometheus.Gauge
queueLength *prometheus.GaugeVec
}

type request struct {
Expand All @@ -96,11 +96,11 @@ func New(cfg Config, log log.Logger, registerer prometheus.Registerer) (*Fronten
Help: "Time spend by requests queued.",
Buckets: prometheus.DefBuckets,
}),
queueLength: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{
queueLength: promauto.With(registerer).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "cortex",
Name: "query_frontend_queue_length",
Help: "Number of queries in the queue.",
}),
}, []string{"user"}),
connectedClients: atomic.NewInt32(0),
}
f.cond = sync.NewCond(&f.mtx)
Expand Down Expand Up @@ -363,7 +363,7 @@ func (f *Frontend) queueRequest(ctx context.Context, req *request) error {

select {
case queue <- req:
f.queueLength.Add(1)
f.queueLength.WithLabelValues(userID).Add(1)
f.cond.Broadcast()
return nil
default:
Expand Down