Skip to content

Commit 5201e20

Browse files
committed
feat: Add metric for provisioner daemons
So we can alert on provisioner saturation/capacity.
1 parent 0413ed0 commit 5201e20

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

cli/server.go

+1
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
822822
}
823823
provisionerDaemons = append(provisionerDaemons, daemon)
824824
}
825+
provisionerdMetrics.Runner.NumDaemons.Set(float64(len(provisionerDaemons)))
825826

826827
shutdownConnsCtx, shutdownConns := context.WithCancel(ctx)
827828
defer shutdownConns()

provisionerd/provisionerd.go

+6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ func NewMetrics(reg prometheus.Registerer) Metrics {
140140
Name: "jobs_current",
141141
Help: "The number of currently running provisioner jobs.",
142142
}, []string{"provisioner"}),
143+
NumDaemons: auto.NewGauge(prometheus.GaugeOpts{
144+
Namespace: "coderd",
145+
Subsystem: "provisionerd",
146+
Name: "num_daemons",
147+
Help: "The number of provisioner daemons.",
148+
}),
143149
JobTimings: auto.NewHistogramVec(prometheus.HistogramOpts{
144150
Namespace: "coderd",
145151
Subsystem: "provisionerd",

provisionerd/runner/runner.go

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type Runner struct {
8888

8989
type Metrics struct {
9090
ConcurrentJobs *prometheus.GaugeVec
91+
NumDaemons prometheus.Gauge
9192
// JobTimings also counts the total amount of jobs.
9293
JobTimings *prometheus.HistogramVec
9394
// WorkspaceBuilds counts workspace build successes and failures.

0 commit comments

Comments
 (0)