Skip to content

Commit

Permalink
Collect general machine issue info and lower last event error thresho…
Browse files Browse the repository at this point in the history
…ld. (#13)
  • Loading branch information
Gerrit91 authored Oct 16, 2023
1 parent b64f73d commit acf9977
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion metalCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type metalCollector struct {

machineAllocationInfo *prometheus.Desc
machineIssues *prometheus.Desc
machineIssuesInfo *prometheus.Desc

projectInfo *prometheus.Desc

Expand Down Expand Up @@ -129,6 +130,11 @@ func newMetalCollector(client metalgo.Client) *metalCollector {
"Provide information about the machine allocation",
[]string{"machineid", "partition", "machinename", "clusterTag", "primaryASN", "role"}, nil,
),
machineIssuesInfo: prometheus.NewDesc(
"metal_machine_issues_info",
"Provide general information on issues that are evaluated by the metal-api",
[]string{"issueid", "description", "severity", "refurl"}, nil,
),
machineIssues: prometheus.NewDesc(
"metal_machine_issues",
"Provide information on machine issues",
Expand Down Expand Up @@ -162,6 +168,7 @@ func (collector *metalCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- collector.switchSyncDurationsMs
ch <- collector.machineAllocationInfo
ch <- collector.machineIssues
ch <- collector.machineIssuesInfo
}

func (collector *metalCollector) Collect(ch chan<- prometheus.Metric) {
Expand Down Expand Up @@ -268,7 +275,9 @@ func (collector *metalCollector) Collect(ch chan<- prometheus.Metric) {
panic(err)
}

issues, err := collector.client.Machine().Issues(machine.NewIssuesParams().WithBody(&models.V1MachineIssuesRequest{}), nil)
issues, err := collector.client.Machine().Issues(machine.NewIssuesParams().WithBody(&models.V1MachineIssuesRequest{
LastErrorThreshold: pointer.Pointer(int64(1 * time.Hour)),
}), nil)
if err != nil {
panic(err)
}
Expand All @@ -293,6 +302,8 @@ func (collector *metalCollector) Collect(ch chan<- prometheus.Metric) {
}

allIssuesByID[*issue.ID] = true

ch <- prometheus.MustNewConstMetric(collector.machineIssuesInfo, prometheus.GaugeValue, 1.0, *issue.ID, pointer.SafeDeref(issue.Description), pointer.SafeDeref(issue.Severity), pointer.SafeDeref(issue.RefURL))
}

for _, m := range machines.Payload {
Expand Down

0 comments on commit acf9977

Please sign in to comment.