@@ -20,6 +20,7 @@ const (
20
20
labelKeyJobName = "job_name"
21
21
labelKeyEventName = "event_name"
22
22
labelKeyJobResult = "job_result"
23
+ labelKeyRunnerPodName = "pod_name"
23
24
)
24
25
25
26
const githubScaleSetSubsystem = "gha"
47
48
startedJobsTotalLabels = jobLabels
48
49
lastJobStartupDurationLabels = jobLabels
49
50
jobQueueDurationLabels = jobLabels
51
+ runnerLabels = append (jobLabels , labelKeyRunnerPodName )
50
52
)
51
53
52
54
var (
@@ -168,6 +170,15 @@ var (
168
170
},
169
171
lastJobExecutionDurationLabels ,
170
172
)
173
+
174
+ runnerJob = prometheus .NewGaugeVec (
175
+ prometheus.GaugeOpts {
176
+ Subsystem : githubScaleSetSubsystem ,
177
+ Name : "runner_job" ,
178
+ Help : "Job information for the runner." ,
179
+ },
180
+ runnerLabels ,
181
+ )
171
182
)
172
183
173
184
type baseLabels struct {
@@ -212,6 +223,12 @@ func (b *baseLabels) startedJobLabels(msg *actions.JobStarted) prometheus.Labels
212
223
return l
213
224
}
214
225
226
+ func (b * baseLabels ) runnerLabels (msg * actions.JobMessageBase , runnerName string ) prometheus.Labels {
227
+ l := b .jobLabels (msg )
228
+ l [labelKeyRunnerPodName ] = runnerName
229
+ return l
230
+ }
231
+
215
232
//go:generate mockery --name Publisher --output ./mocks --outpkg mocks --case underscore
216
233
type Publisher interface {
217
234
PublishStatic (min , max int )
@@ -268,6 +285,7 @@ func NewExporter(config ExporterConfig) ServerPublisher {
268
285
jobLastQueueDurationSeconds ,
269
286
jobLastStartupDurationSeconds ,
270
287
jobLastExecutionDurationSeconds ,
288
+ runnerJob ,
271
289
)
272
290
273
291
mux := http .NewServeMux ()
@@ -334,6 +352,9 @@ func (e *exporter) PublishJobStarted(msg *actions.JobStarted) {
334
352
queueDuration := msg .JobMessageBase .RunnerAssignTime .Unix () - msg .JobMessageBase .QueueTime .Unix ()
335
353
jobLastQueueDurationSeconds .With (l ).Set (float64 (queueDuration ))
336
354
}
355
+
356
+ rl := e .runnerLabels (& msg .JobMessageBase , msg .RunnerName )
357
+ runnerJob .With (rl ).Set (1 )
337
358
}
338
359
339
360
func (e * exporter ) PublishJobCompleted (msg * actions.JobCompleted ) {
@@ -344,6 +365,9 @@ func (e *exporter) PublishJobCompleted(msg *actions.JobCompleted) {
344
365
executionDuration := msg .JobMessageBase .FinishTime .Unix () - msg .JobMessageBase .RunnerAssignTime .Unix ()
345
366
jobLastExecutionDurationSeconds .With (l ).Set (float64 (executionDuration ))
346
367
}
368
+
369
+ rl := e .runnerLabels (& msg .JobMessageBase , msg .RunnerName )
370
+ runnerJob .Delete (rl )
347
371
}
348
372
349
373
func (m * exporter ) PublishDesiredRunners (count int ) {
0 commit comments