Skip to content

Commit 227bfb1

Browse files
committed
Add more detail to alerts
1 parent 372f430 commit 227bfb1

File tree

6 files changed

+48
-37
lines changed

6 files changed

+48
-37
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GOTEST=$(GOCMD) test
44
GOVET=$(GOCMD) vet
55
BINARY_NAME=pure-fa-om-exporter
66
MODULE_NAME=purestorage/fa-openmetrics-exporter
7-
VERSION?=1.0.11
7+
VERSION?=1.0.12
88
SERVICE_PORT?=9490
99
DOCKER_REGISTRY?= quay.io/purestorage/
1010
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true

build/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM golang:alpine as build
2-
ARG VERSION=1.0.11
2+
ARG VERSION=1.0.12
33

44
WORKDIR /usr/src/app
55

docs/deployment-examples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Deploying the binary requires [go](https://go.dev) to compile the code and runni
144144
```console
145145
$ ls out/bin
146146
$ .out/bin/pure-fa-openmetrics-exporter
147-
Start Pure FlashArray exporter v1.0.11 on 0.0.0.0:9490
147+
Start Pure FlashArray exporter v1.0.12 on 0.0.0.0:9490
148148
```
149149

150150
2. **Test the exporter**
@@ -234,7 +234,7 @@ Follow steps 1-4 and 7-8 of the default binary deployment, but substitute the fo
234234
```console
235235
$ ls out/bin
236236
$ .out/bin/pure-fa-openmetrics-exporter --tokens /directorypath/tokens.yaml
237-
Start Pure FlashArray exporter v1.0.11 on 0.0.0.0:9490
237+
Start Pure FlashArray exporter v1.0.12 on 0.0.0.0:9490
238238
```
239239

240240
3. **Test the exporter**
@@ -333,4 +333,4 @@ Create the certificate and key and pass the exporter the files. There are many d
333333
Full check using certificate.
334334
```console
335335
$ curl --cacert pure-ome.crt -H 'Authorization: Bearer 11111111-1111-1111-1111-111111111111' -X GET 'http://pure-ome.fqdn.com:9490/metrics/array?endpoint=array01'
336-
```
336+
```

internal/openmetrics-exporter/alerts_collector.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
client "purestorage/fa-openmetrics-exporter/internal/rest-client"
66
"strings"
7-
7+
"strconv"
88
"github.com/prometheus/client_golang/prometheus"
99
)
1010

@@ -24,15 +24,22 @@ func (c *AlertsCollector) Collect(ch chan<- prometheus.Metric) {
2424
}
2525
al := make(map[string]float64)
2626
for _, alert := range alerts.Items {
27-
al[fmt.Sprintf("%s,%s", alert.ComponentType, alert.Severity)] += 1
27+
al[fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s",
28+
alert.ComponentType,
29+
alert.Severity,
30+
strconv.Itoa(alert.Created),
31+
alert.Name,
32+
strconv.Itoa(alert.Code),
33+
alert.Summary,
34+
alert.Issue)] += 1
2835
}
2936
for a, n := range al {
3037
alert := strings.Split(a, ",")
3138
ch <- prometheus.MustNewConstMetric(
3239
c.AlertsDesc,
3340
prometheus.GaugeValue,
3441
n,
35-
alert[0], alert[1],
42+
alert[0], alert[1], alert[2], alert[3], alert[4], alert[5], alert[6],
3643
)
3744
}
3845
}
@@ -42,7 +49,7 @@ func NewAlertsCollector(fa *client.FAClient) *AlertsCollector {
4249
AlertsDesc: prometheus.NewDesc(
4350
"purefa_alerts_open",
4451
"FlashArray open alert events",
45-
[]string{"component_type", "severity"},
52+
[]string{"component_type", "severity", "created", "name", "code", "summary", "issue"},
4653
prometheus.Labels{},
4754
),
4855
Client: fa,
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
package collectors
22

3-
43
import (
4+
"encoding/json"
55
"fmt"
6-
"testing"
7-
"regexp"
8-
"strings"
96
"net/http"
107
"net/http/httptest"
11-
"encoding/json"
128
"os"
13-
14-
"purestorage/fa-openmetrics-exporter/internal/rest-client"
9+
client "purestorage/fa-openmetrics-exporter/internal/rest-client"
10+
"regexp"
11+
"strings"
12+
"testing"
1513
)
1614

1715
func TestAlertsCollector(t *testing.T) {
@@ -24,38 +22,39 @@ func TestAlertsCollector(t *testing.T) {
2422
json.Unmarshal(ropen, &aopen)
2523
json.Unmarshal(rall, &aall)
2624
server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
27-
urlall := regexp.MustCompile(`^/api/([0-9]+.[0-9]+)?/alerts$`)
28-
urlopen := regexp.MustCompile(`^/api/([0-9]+.[0-9]+)?/alerts\?filter=state%3D%27open%27$`)
29-
if r.URL.Path == "/api/api_version" {
30-
w.Header().Set("Content-Type", "application/json")
31-
w.WriteHeader(http.StatusOK)
25+
urlall := regexp.MustCompile(`^/api/([0-9]+.[0-9]+)?/alerts$`)
26+
urlopen := regexp.MustCompile(`^/api/([0-9]+.[0-9]+)?/alerts\?filter=state%3D%27open%27$`)
27+
if r.URL.Path == "/api/api_version" {
28+
w.Header().Set("Content-Type", "application/json")
29+
w.WriteHeader(http.StatusOK)
3230
w.Write([]byte(vers))
33-
} else if urlopen.MatchString(r.URL.Path + "?" + r.URL.RawQuery) {
31+
} else if urlopen.MatchString(r.URL.Path + "?" + r.URL.RawQuery) {
3432
w.Header().Set("x-auth-token", "faketoken")
3533
w.Header().Set("Content-Type", "application/json")
3634
w.WriteHeader(http.StatusOK)
3735
w.Write([]byte(ropen))
38-
} else if urlall.MatchString(r.URL.Path) {
36+
} else if urlall.MatchString(r.URL.Path) {
3937
w.Header().Set("x-auth-token", "faketoken")
4038
w.Header().Set("Content-Type", "application/json")
4139
w.WriteHeader(http.StatusOK)
4240
w.Write([]byte(rall))
4341
}
44-
}))
45-
endp := strings.Split(server.URL, "/")
46-
e := endp[len(endp)-1]
47-
al := make(map[string]float64)
48-
for _, a := range aopen.Items {
49-
al[fmt.Sprintf("%s,%s", a.ComponentType, a.Severity)] += 1
50-
}
42+
}))
43+
endp := strings.Split(server.URL, "/")
44+
e := endp[len(endp)-1]
45+
al := make(map[string]float64)
46+
for _, a := range aopen.Items {
47+
al[fmt.Sprintf("%s,%s", a.ComponentType, a.Severity, a.Created, a.Name, a.Code, a.Summary, a.Issue)] += 1
48+
}
5149
want := make(map[string]bool)
52-
for a, n := range al {
53-
alert := strings.Split(a, ",")
54-
// want[fmt.Sprintf("label:{name:\"component_type\" value:\"%s\"} label:{name:\"severity\" value:\"%s\"} gauge:{value:%g}", alert[0], alert[1], n)] = true
55-
want[fmt.Sprintf("label:{name:\"component_type\" value:\"%s\"} label:{name:\"severity\" value:\"%s\"} gauge:{value:%g}", alert[0], alert[1], n)] = true
50+
for a, n := range al {
51+
alert := strings.Split(a, ",")
52+
// want[fmt.Sprintf("label:{name:\"component_type\" value:\"%s\"} label:{name:\"severity\" value:\"%s\"} gauge:{value:%g}", alert[0], alert[1], n)] = true
53+
// want[fmt.Sprintf("label:{name:\"component_type\" value:\"%s\"} label:{name:\"severity\" value:\"%s\"} gauge:{value:%g}", alert[0], alert[1], n)] = true
54+
want[fmt.Sprintf("label:{name:\"component_type\" value:\"%s\"} label:{name:\"severity\" value:\"%s\"} gauge:{value:%g}", alert[0], alert[1], alert[2], alert[3], alert[4], alert[5], alert[6], n)] = true
5655
}
57-
c := client.NewRestClient(e, "fake-api-token", "latest", false)
56+
c := client.NewRestClient(e, "fake-api-token", "latest", false)
5857
ac := NewAlertsCollector(c)
59-
metricsCheck(t, ac, want)
60-
server.Close()
58+
metricsCheck(t, ac, want)
59+
server.Close()
6160
}

specification/metrics/purefa-metrics.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ This document describes the semantic conventions for Pure FlashArray Metrics.
6666
| --------- | ------------------ | ---------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | ------------------------------------------------------------------------------------------------------------------ |
6767
| Available | purefa_alerts_open | FlashArray open alert events | | Gauge | Double | `component_type` | `chassis`, `drive_bay`, `nvram_bay`, `power_supply`, `temp_sensor`, `controller`, `eth_port`, `cooling`, `fc_port` |
6868
| | | | | | | `severity` | `info`, `warning`, `critical`, `hidden` |
69+
| | | | | | | `created` | (time the alert was created in milliseconds since the UNIX epoch) |
70+
| | | | | | | `name` | (a locally unique, system-generated name) |
71+
| | | | | | | `code` | (code number of the event) |
72+
| | | | | | | `summary` | (summary of the alert) |
73+
| | | | | | | `issue` | (information about the alert cause) |
6974

7075

7176
### `purefa_array` - FlashArray metrics

0 commit comments

Comments
 (0)