Skip to content

Add a worker time-spent-idle counter to the ruler #727

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 1 commit into from
Feb 28, 2018
Merged
Changes from all 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
9 changes: 9 additions & 0 deletions pkg/ruler/ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ var (
Name: "blocked_workers",
Help: "How many workers are waiting on an item to be ready.",
})
workerIdleTime = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "cortex",
Name: "worker_idle_seconds_total",
Help: "How long workers have spent waiting for work.",
})
evalLatency = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "cortex",
Name: "group_evaluation_latency_seconds",
Expand All @@ -68,6 +73,7 @@ func init() {
prometheus.MustRegister(evalLatency)
prometheus.MustRegister(rulesProcessed)
prometheus.MustRegister(blockedWorkers)
prometheus.MustRegister(workerIdleTime)
}

// Config is the configuration for the recording rules server.
Expand Down Expand Up @@ -460,15 +466,18 @@ func (w *worker) Run() {
return
default:
}
waitStart := time.Now()
blockedWorkers.Inc()
level.Debug(util.Logger).Log("msg", "waiting for next work item")
item := w.scheduler.nextWorkItem()
blockedWorkers.Dec()
waitElapsed := time.Now().Sub(waitStart)
if item == nil {
level.Debug(util.Logger).Log("msg", "queue closed and empty; terminating worker")
return
}
evalLatency.Observe(time.Since(item.scheduled).Seconds())
workerIdleTime.Add(waitElapsed.Seconds())
level.Debug(util.Logger).Log("msg", "processing item", "item", item)
w.ruler.Evaluate(item.userID, item)
w.scheduler.workItemDone(*item)
Expand Down