From 913b1787d44896447057f4974b6aea055f2eb297 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 23 Oct 2023 14:47:22 +0200 Subject: [PATCH] Add machine state to machine allocation info. This information is interesting as it marks a machine that is locked for being investigated by an operator. This way, an operator can silence alerts by locking a machine. --- metalCollector.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/metalCollector.go b/metalCollector.go index a2dee47..b36224a 100644 --- a/metalCollector.go +++ b/metalCollector.go @@ -128,7 +128,7 @@ func newMetalCollector(client metalgo.Client) *metalCollector { machineAllocationInfo: prometheus.NewDesc( "metal_machine_allocation_info", "Provide information about the machine allocation", - []string{"machineid", "partition", "machinename", "clusterTag", "primaryASN", "role"}, nil, + []string{"machineid", "partition", "machinename", "clusterTag", "primaryASN", "role", "state"}, nil, ), machineIssuesInfo: prometheus.NewDesc( "metal_machine_issues_info", @@ -319,6 +319,7 @@ func (collector *metalCollector) Collect(ch chan<- prometheus.Metric) { hostname = "NOTALLOCATED" clusterID = "NOTALLOCATED" primaryASN = "NOTALLOCATED" + state = pointer.SafeDeref(pointer.SafeDeref(m.State).Value) ) if m.Allocation != nil { @@ -342,7 +343,7 @@ func (collector *metalCollector) Collect(ch chan<- prometheus.Metric) { partitionID = *m.Partition.ID } - ch <- prometheus.MustNewConstMetric(collector.machineAllocationInfo, prometheus.GaugeValue, 1.0, *m.ID, partitionID, hostname, clusterID, primaryASN, role) + ch <- prometheus.MustNewConstMetric(collector.machineAllocationInfo, prometheus.GaugeValue, 1.0, *m.ID, partitionID, hostname, clusterID, primaryASN, role, state) for issueID := range allIssuesByID { machineIssues, ok := issuesByMachineID[*m.ID]