Skip to content

Commit a2b9127

Browse files
authored
feat(prometheus): Add runner type to prometheus metric (#1161)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent 2eeacac commit a2b9127

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/controlplane/pkg/biz/orgmetrics.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func (uc *OrgMetricsUseCase) GetLastWorkflowStatusByRun(ctx context.Context, org
193193
OrgName: orgName,
194194
WorkflowName: wf.Name,
195195
Status: wf.LastRun.State,
196+
Runner: wf.LastRun.RunnerType,
196197
})
197198
}
198199

app/controlplane/pkg/metrics/prometheus/collector/collector.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type WorkflowLastStatusByRunReport struct {
3232
WorkflowName string `json:"workflow_name"`
3333
OrgName string `json:"org_name"`
3434
Status string `json:"status"`
35+
Runner string `json:"runner"`
3536
}
3637

3738
// ChainloopCollector is a base implementation of the ChainloopCollector interface
@@ -52,7 +53,7 @@ func NewChainloopCollector(orgName string, gatherer ChainloopMetricsGatherer, lo
5253
workflowLastRunSuccessful: prometheus.NewGaugeVec(prometheus.GaugeOpts{
5354
Name: "chainloop_workflow_up",
5455
Help: "Indicate if the last run was successful.",
55-
}, []string{"org", "workflow"}),
56+
}, []string{"org", "workflow", "runner"}),
5657
logger: log.NewHelper(log.With(logger, "component", "collector/prometheus")),
5758
}
5859
}
@@ -72,9 +73,9 @@ func (bcc *ChainloopCollector) Collect(ch chan<- prometheus.Metric) {
7273

7374
for _, r := range wfReports {
7475
if r.Status == "success" {
75-
bcc.workflowLastRunSuccessful.WithLabelValues(r.OrgName, r.WorkflowName).Set(1)
76+
bcc.workflowLastRunSuccessful.WithLabelValues(r.OrgName, r.WorkflowName, r.Runner).Set(1)
7677
} else {
77-
bcc.workflowLastRunSuccessful.WithLabelValues(r.OrgName, r.WorkflowName).Set(0)
78+
bcc.workflowLastRunSuccessful.WithLabelValues(r.OrgName, r.WorkflowName, r.Runner).Set(0)
7879
}
7980
}
8081

0 commit comments

Comments
 (0)