Skip to content

Commit

Permalink
Add machine state to machine allocation info.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gerrit91 committed Oct 23, 2023
1 parent acf9977 commit 913b178
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions metalCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand All @@ -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]
Expand Down

0 comments on commit 913b178

Please sign in to comment.