Skip to content

Commit 95d4916

Browse files
authored
Merge branch 'main' into fix-rc-delete
2 parents c3d9d72 + 0bf8af1 commit 95d4916

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

docs/metrics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Starting with version `2.10.0`, the operator introduces HCP Terraform–specific
1212

1313
| Metric name | Type | Description | Controller | Status |
1414
|-------------|------|-------------|------------|--------|
15-
| `hcp_tf_runs{run_status="<HCP Terraform Run Status>"}` | Gauge | Pending runs by statuses. | RunsCollector | Alpha |
16-
| `hcp_tf_runs_total` | Gauge | Total number of pending Runs by statuses. | RunsCollector | Alpha |
15+
| `hcp_tf_runs{run_status, agent_pool_id, agent_pool_name}` | Gauge | Pending runs by statuses. | RunsCollector | Alpha |
16+
| `hcp_tf_runs_total{agent_pool_id, agent_pool_name}` | Gauge | Total number of pending Runs. | RunsCollector | Alpha |
1717

1818
## Scraping Metrics
1919

internal/controller/metrics.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ var (
1717
},
1818
// TODO:
1919
// - Add a status label to indicate whether the metric is up or down
20-
// (for example, when an endpoint is unreachable or the CR is suspended).
21-
// - Add agent_pool_name as label.
22-
// - Add agent_pool_id as label.
20+
// (for example, when an endpoint is unreachable or the CR is suspended/paused).
2321
[]string{
2422
"run_status",
23+
"agent_pool_id",
24+
"agent_pool_name",
2525
},
2626
)
2727
metricRunsTotal = prometheus.NewGaugeVec(
@@ -31,10 +31,11 @@ var (
3131
},
3232
// TODO:
3333
// - Add a status label to indicate whether the metric is up or down
34-
// (for example, when an endpoint is unreachable or the CR is suspended).
35-
// - Add agent_pool_name as label.
36-
// - Add agent_pool_id as label.
37-
[]string{},
34+
// (for example, when an endpoint is unreachable or the CR is suspended/paused).
35+
[]string{
36+
"agent_pool_id",
37+
"agent_pool_name",
38+
},
3839
)
3940
// TODO:
4041
// - Add a metric to track associated Workspaces.

internal/controller/runscollector_controller.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,18 @@ func (r *RunsCollectorReconciler) reconcileRuns(ctx context.Context, rc *runsCol
309309
}
310310

311311
for _, status := range runStatuses {
312-
metricRuns.WithLabelValues(string(status)).Set(float64(runs[status]))
312+
metricRuns.WithLabelValues(
313+
string(status), // run_status
314+
rc.instance.Status.AgentPool.ID, // agent_pool_id
315+
rc.instance.Status.AgentPool.Name, // agent_pool_name
316+
).Set(float64(runs[status]))
313317
}
314318

315319
rc.log.Info("Reconcile Runs Collector", "msg", fmt.Sprintf("Total Runs: %.0f", runsTotal))
316-
metricRunsTotal.WithLabelValues().Set(runsTotal)
320+
metricRunsTotal.WithLabelValues(
321+
rc.instance.Status.AgentPool.ID, // agent_pool_id
322+
rc.instance.Status.AgentPool.Name, // agent_pool_name
323+
).Set(runsTotal)
317324

318325
rc.instance.Status.ObservedGeneration = rc.instance.Generation
319326

0 commit comments

Comments
 (0)