Skip to content

Commit 04ad46f

Browse files
authored
Merge pull request #97 from PureStorage-OpenConnect/issue_94
Add more detail to alerts
2 parents 372f430 + c905e2a commit 04ad46f

File tree

9 files changed

+84
-71
lines changed

9 files changed

+84
-71
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+
```

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
1919
github.com/prometheus/common v0.45.0 // indirect
2020
github.com/prometheus/procfs v0.12.0 // indirect
21-
golang.org/x/net v0.18.0 // indirect
22-
golang.org/x/sys v0.14.0 // indirect
21+
golang.org/x/net v0.19.0 // indirect
22+
golang.org/x/sys v0.15.0 // indirect
2323
google.golang.org/protobuf v1.31.0 // indirect
2424
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
3838
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
3939
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
4040
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
41-
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
42-
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
41+
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
42+
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
4343
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
4444
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
4545
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -51,8 +51,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
5151
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5252
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5353
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
54-
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
55-
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
54+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
55+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
5656
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
5757
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
5858
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=

internal/openmetrics-exporter/alerts_collector.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,24 @@ 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,%d,%s,%d,%s,%s,%s,%s",
28+
alert.Category,
29+
alert.Code,
30+
alert.ComponentType,
31+
alert.Created,
32+
alert.Issue,
33+
alert.Name,
34+
alert.Severity,
35+
alert.Summary,
36+
)] += 1
2837
}
2938
for a, n := range al {
3039
alert := strings.Split(a, ",")
3140
ch <- prometheus.MustNewConstMetric(
3241
c.AlertsDesc,
3342
prometheus.GaugeValue,
3443
n,
35-
alert[0], alert[1],
44+
alert[0], alert[1], alert[2], alert[3], alert[4], alert[5], alert[6], alert[7],
3645
)
3746
}
3847
}
@@ -42,7 +51,7 @@ func NewAlertsCollector(fa *client.FAClient) *AlertsCollector {
4251
AlertsDesc: prometheus.NewDesc(
4352
"purefa_alerts_open",
4453
"FlashArray open alert events",
45-
[]string{"component_type", "severity"},
54+
[]string{"category", "code", "component_type", "created", "issue", "name", "severity", "summary"},
4655
prometheus.Labels{},
4756
),
4857
Client: fa,
Lines changed: 26 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,38 @@ 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,%d,%s,%d,%s,%s,%s,%s", a.Category, a.Code, a.ComponentType, a.Created, a.Issue, a.Name, a.Severity, a.Summary)] += 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+
53+
want[fmt.Sprintf("label:{name:\"category\" value:\"%s\"} label:{name:\"code\" value:\"%s\"} label:{name:\"component_type\" value:\"%s\"} label:{name:\"created\" value:\"%s\"} label:{name:\"issue\" value:\"%s\"} label:{name:\"name\" value:\"%s\"} label:{name:\"severity\" value:\"%s\"} label:{name:\"summary\" value:\"%s\"} gauge:{value:%g}", alert[0], alert[1], alert[2], alert[3], alert[4], alert[5], alert[6], alert[7], n)] = true
5654
}
57-
c := client.NewRestClient(e, "fake-api-token", "latest", false)
55+
c := client.NewRestClient(e, "fake-api-token", "latest", false)
5856
ac := NewAlertsCollector(c)
59-
metricsCheck(t, ac, want)
60-
server.Close()
57+
metricsCheck(t, ac, want)
58+
server.Close()
6159
}

internal/rest-client/alerts.go

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
package client
22

3-
43
type Alert struct {
5-
Id string `json:"id"`
6-
Name string `json:"name"`
7-
Actual string `json:"actual"`
8-
Closed int `json:"closed"`
9-
Code int `json:"code"`
10-
ComponentName string `json:"component_name"`
11-
ComponentType string `json:"component_type"`
12-
Created int `json:"created"`
13-
Description string `json:"description"`
14-
Expected string `json:"expected"`
15-
Flagged bool `json:"flagged"`
16-
Issue string `json:"issue"`
17-
Index int `json:"index"`
18-
KnowledgeBaseUrl string `json:"knowledge_base_url"`
19-
Notified int `json:"notified"`
20-
Severity string `json:"severity"`
21-
State string `json:"state"`
22-
Summary string `json:"summary"`
23-
Updated int `json:"updated"`
4+
Id string `json:"id"`
5+
Name string `json:"name"`
6+
Actual string `json:"actual"`
7+
Category string `json:"category"`
8+
Closed int64 `json:"closed"`
9+
Code int64 `json:"code"`
10+
ComponentName string `json:"component_name"`
11+
ComponentType string `json:"component_type"`
12+
Created int64 `json:"created"`
13+
Description string `json:"description"`
14+
Expected string `json:"expected"`
15+
Flagged bool `json:"flagged"`
16+
Issue string `json:"issue"`
17+
KnowledgeBaseUrl string `json:"knowledge_base_url"`
18+
Notified int64 `json:"notified"`
19+
Severity string `json:"severity"`
20+
State string `json:"state"`
21+
Summary string `json:"summary"`
22+
Updated int64 `json:"updated"`
2423
}
2524

2625
type AlertsList struct {
27-
ContinuationToken string `json:"continuation_token"`
28-
TotalItemCount int `json:"total_item_count"`
29-
MoreItemsRemaining bool `json:"more_items_remaining"`
30-
Items []Alert `json:"items"`
26+
ContinuationToken string `json:"continuation_token"`
27+
TotalItemCount int32 `json:"total_item_count"`
28+
MoreItemsRemaining bool `json:"more_items_remaining"`
29+
Items []Alert `json:"items"`
3130
}
3231

3332
func (fa *FAClient) GetAlerts(filter string) *AlertsList {
@@ -48,6 +47,6 @@ func (fa *FAClient) GetAlerts(filter string) *AlertsList {
4847
if err != nil {
4948
fa.Error = err
5049
}
51-
50+
5251
return result
5352
}

specification/metrics/purefa-metrics.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,17 @@ This document describes the semantic conventions for Pure FlashArray Metrics.
6262

6363
**Description:** FlashArray Open Alerts
6464

65-
| Status | Name | Description | Units | Metric Type ([*](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#metric-types)) | Value Type | Attribute Key | Attribute Values |
66-
| --------- | ------------------ | ---------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | ------------------------------------------------------------------------------------------------------------------ |
67-
| 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` |
68-
| | | | | | | `severity` | `info`, `warning`, `critical`, `hidden` |
65+
| Status | Name | Description | Units | Metric Type ([*](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#metric-types)) | Value Type | Attribute Key | Attribute Values |
66+
| --------- | ------------------ | ------------------------------------------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------- | ------------------------------------------------------------------------------------------------------------------ |
67+
| Available | purefa_alerts_open | FlashArray open alert event | | Gauge | Double | `name` | (name) |
68+
| | | The code number of the event | | | | `code` | (code) |
69+
| | | | | | | `component_type` | `chassis`, `drive_bay`, `nvram_bay`, `power_supply`, `temp_sensor`, `controller`, `eth_port`, `cooling`, `fc_port` |
70+
| | | The time the alert was created in milliseconds since the UNIX epoch | | | | `created` | (created) |
71+
| | | Information about the alert cause | | | | `issue` | (issue) |
72+
| | | The category of the alert. | | | | `category` | `array`, `hardware`, `software` |
73+
| | | | | | | `severity` | `info`, `warning`, `critical`, `hidden` |
74+
| | | A summary of the alert | | | | `summary` | (summary) |
75+
| |
6976

7077

7178
### `purefa_array` - FlashArray metrics

0 commit comments

Comments
 (0)