Skip to content

Commit f3c66dc

Browse files
committed
Fixed alerts collector
1 parent 9246ca7 commit f3c66dc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/openmetrics-exporter/alerts_collector.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package collectors
22

33

44
import (
5+
"fmt"
6+
"strings"
7+
58
"github.com/prometheus/client_golang/prometheus"
69
"purestorage/fa-openmetrics-exporter/internal/rest-client"
710
)
@@ -20,12 +23,17 @@ func (c *AlertsCollector) Collect(ch chan<- prometheus.Metric) {
2023
if len(alerts.Items) == 0 {
2124
return
2225
}
26+
al := make(map[string]float64)
2327
for _, alert := range alerts.Items {
28+
al[fmt.Sprintf("%s,%s,%s", alert.Severity, alert.ComponentType, alert.ComponentName)] += 1
29+
}
30+
for a, n := range al {
31+
alert := strings.Split(a, ",")
2432
ch <- prometheus.MustNewConstMetric(
2533
c.AlertsDesc,
2634
prometheus.GaugeValue,
27-
1.0,
28-
alert.ComponentName, alert.ComponentType, alert.Severity,
35+
n,
36+
alert[0], alert[1], alert[2],
2937
)
3038
}
3139
}

0 commit comments

Comments
 (0)