Skip to content

Commit

Permalink
Merge pull request #28 from chrroberts-pure/issue14
Browse files Browse the repository at this point in the history
Fix Alerts Labels - Issue 14
  • Loading branch information
sdodsley authored Jan 27, 2023
2 parents 963a45e + 322c34c commit 7d1bcb8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=pure-fa-om-exporter
MODULE_NAME=go mod init purestorage/fa-openmetrics-exporter
VERSION?=1.0.2
VERSION?=1.0.3
SERVICE_PORT?=9490
DOCKER_REGISTRY?= quay.io/purestorage/
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
Expand Down
4 changes: 2 additions & 2 deletions cmd/fa-om-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)

var version string = "1.0.2"
var version string = "1.0.3"
var debug bool = false

func main() {
Expand Down Expand Up @@ -86,7 +86,7 @@ func metricsHandler(w http.ResponseWriter, r *http.Request) {

registry := prometheus.NewRegistry()
faclient := client.NewRestClient(endpoint, apitoken, apiver, debug)
if faclient.Error != nil {
if faclient.Error != nil {
http.Error(w, "Error connecting to FlashArray. Check your management endpoint and/or api token are correct.", http.StatusBadRequest)
return
}
Expand Down
5 changes: 2 additions & 3 deletions internal/openmetrics-exporter/alerts_collector.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package collectors


import (
"fmt"
client "purestorage/fa-openmetrics-exporter/internal/rest-client"
"strings"

"github.com/prometheus/client_golang/prometheus"
"purestorage/fa-openmetrics-exporter/internal/rest-client"
)

type AlertsCollector struct {
Expand All @@ -25,7 +24,7 @@ func (c *AlertsCollector) Collect(ch chan<- prometheus.Metric) {
}
al := make(map[string]float64)
for _, alert := range alerts.Items {
al[fmt.Sprintf("%s,%s,%s", alert.Severity, alert.ComponentType, alert.ComponentName)] += 1
al[fmt.Sprintf("%s,%s,%s", alert.ComponentName, alert.ComponentType, alert.Severity)] += 1
}
for a, n := range al {
alert := strings.Split(a, ",")
Expand Down

0 comments on commit 7d1bcb8

Please sign in to comment.