Skip to content

Commit 4a0677d

Browse files
authored
Merge pull request #83 from PureStorage-OpenConnect/81-82-v1013a
Alerts Fix, and adding `object-store-accounts`
2 parents d0a96e8 + 92b771b commit 4a0677d

14 files changed

+2281
-131
lines changed

internal/openmetrics-exporter/alerts_collector.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ func (c *AlertsCollector) Collect(ch chan<- prometheus.Metric) {
2525
al := make(map[string]float64)
2626
for _, alert := range alerts.Items {
2727
al[fmt.Sprintf("%s\n%d\n%s\n%s\n%d\n%s\n%s\n%s",
28-
alert.Action,
28+
strings.Replace(alert.Action, "\n", " ", -1),
2929
alert.Code,
3030
alert.ComponentName,
3131
alert.ComponentType,
3232
alert.Created,
3333
alert.KBurl,
3434
alert.Severity,
35-
alert.Summary,
36-
)] += 1
35+
strings.Replace(alert.Summary, "\n", " ", -1))] += 1
3736
}
3837
for a, n := range al {
3938
alert := strings.Split(a, "\n")

internal/openmetrics-exporter/alerts_collector_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ func TestAlertsCollector(t *testing.T) {
4444
e := endp[len(endp)-1]
4545
al := make(map[string]float64)
4646
for _, a := range aopen.Items {
47-
al[fmt.Sprintf("%s\n%d\n%s\n%s\n%d\n%s\n%s\n%s", a.Action, a.Code, a.ComponentName, a.ComponentType, a.Created, a.KBurl, a.Severity, a.Summary)] += 1
47+
al[fmt.Sprintf("%s\n%d\n%s\n%s\n%d\n%s\n%s\n%s",
48+
strings.Replace(a.Action, "\n", " ", -1),
49+
a.Code,
50+
a.ComponentName,
51+
a.ComponentType,
52+
a.Created,
53+
a.KBurl,
54+
a.Severity,
55+
strings.Replace(a.Summary, "\n", " ", -1))] += 1
4856
}
4957
want := make(map[string]bool)
5058
for a, n := range al {

internal/openmetrics-exporter/arrays_space_collector.go

Lines changed: 90 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,94 @@ func (c *ArraySpaceCollector) Collect(ch chan<- prometheus.Metric) {
2828
}
2929

3030
as := arrayspace.Items[0]
31-
ch <- prometheus.MustNewConstMetric(
32-
c.ReductionDesc,
33-
prometheus.GaugeValue,
34-
float64(as.Space.DataReduction),
35-
t,
36-
)
37-
ch <- prometheus.MustNewConstMetric(
38-
c.SpaceDesc,
39-
prometheus.GaugeValue,
40-
float64(as.Space.Destroyed),
41-
t, "destroyed",
42-
)
43-
ch <- prometheus.MustNewConstMetric(
44-
c.SpaceDesc,
45-
prometheus.GaugeValue,
46-
float64(as.Space.DestroyedVirtual),
47-
t, "destroyed_virtual",
48-
)
49-
ch <- prometheus.MustNewConstMetric(
50-
c.SpaceDesc,
51-
prometheus.GaugeValue,
52-
float64(as.Space.Snapshots),
53-
t, "snapshots",
54-
)
55-
ch <- prometheus.MustNewConstMetric(
56-
c.SpaceDesc,
57-
prometheus.GaugeValue,
58-
float64(as.Space.TotalPhysical),
59-
t, "total_physical",
60-
)
61-
ch <- prometheus.MustNewConstMetric(
62-
c.SpaceDesc,
63-
prometheus.GaugeValue,
64-
float64(as.Space.Unique),
65-
t, "unique",
66-
)
67-
ch <- prometheus.MustNewConstMetric(
68-
c.SpaceDesc,
69-
prometheus.GaugeValue,
70-
float64(as.Space.Virtual),
71-
t, "virtual",
72-
)
31+
if as.Space.DataReduction != nil {
32+
ch <- prometheus.MustNewConstMetric(
33+
c.ReductionDesc,
34+
prometheus.GaugeValue,
35+
float64(*as.Space.DataReduction),
36+
t,
37+
)
38+
}
39+
if as.Space.Snapshots != nil {
40+
ch <- prometheus.MustNewConstMetric(
41+
c.SpaceDesc,
42+
prometheus.GaugeValue,
43+
float64(*as.Space.Snapshots),
44+
t, "snapshots",
45+
)
46+
}
47+
if as.Space.TotalPhysical != nil {
48+
ch <- prometheus.MustNewConstMetric(
49+
c.SpaceDesc,
50+
prometheus.GaugeValue,
51+
float64(*as.Space.TotalPhysical),
52+
t, "total_physical",
53+
)
54+
}
55+
if as.Space.Unique != nil {
56+
ch <- prometheus.MustNewConstMetric(
57+
c.SpaceDesc,
58+
prometheus.GaugeValue,
59+
float64(*as.Space.Unique),
60+
t, "unique",
61+
)
62+
}
63+
if as.Space.Virtual != nil {
64+
ch <- prometheus.MustNewConstMetric(
65+
c.SpaceDesc,
66+
prometheus.GaugeValue,
67+
float64(*as.Space.Virtual),
68+
t, "virtual",
69+
)
70+
}
71+
if as.Space.TotalProvisioned != nil {
72+
ch <- prometheus.MustNewConstMetric(
73+
c.SpaceDesc,
74+
prometheus.GaugeValue,
75+
float64(*as.Space.TotalProvisioned),
76+
t, "total_provisioned",
77+
)
78+
}
79+
if as.Space.AvailableProvisioned != nil {
80+
ch <- prometheus.MustNewConstMetric(
81+
c.SpaceDesc,
82+
prometheus.GaugeValue,
83+
float64(*as.Space.AvailableProvisioned),
84+
t, "available_provisioned",
85+
)
86+
}
87+
if as.Space.AvailableRatio != nil {
88+
ch <- prometheus.MustNewConstMetric(
89+
c.SpaceDesc,
90+
prometheus.GaugeValue,
91+
float64(*as.Space.AvailableRatio),
92+
t, "available_ratio",
93+
)
94+
}
95+
if as.Space.Destroyed != nil {
96+
ch <- prometheus.MustNewConstMetric(
97+
c.SpaceDesc,
98+
prometheus.GaugeValue,
99+
float64(*as.Space.Destroyed),
100+
t, "destroyed",
101+
)
102+
}
103+
if as.Space.DestroyedVirtual != nil {
104+
ch <- prometheus.MustNewConstMetric(
105+
c.SpaceDesc,
106+
prometheus.GaugeValue,
107+
float64(*as.Space.DestroyedVirtual),
108+
t, "destroyed_virtual",
109+
)
110+
}
111+
if as.Space.Shared != nil {
112+
ch <- prometheus.MustNewConstMetric(
113+
c.SpaceDesc,
114+
prometheus.GaugeValue,
115+
float64(*as.Space.Shared),
116+
t, "shared",
117+
)
118+
}
73119
ch <- prometheus.MustNewConstMetric(
74120
c.ParityDesc,
75121
prometheus.GaugeValue,
@@ -87,13 +133,13 @@ func (c *ArraySpaceCollector) Collect(ch chan<- prometheus.Metric) {
87133
ch <- prometheus.MustNewConstMetric(
88134
c.SpaceDesc,
89135
prometheus.GaugeValue,
90-
float64(as.Capacity-as.Space.TotalPhysical),
136+
float64(as.Capacity-*as.Space.TotalPhysical),
91137
t, "empty",
92138
)
93139
ch <- prometheus.MustNewConstMetric(
94140
c.UtilizationDesc,
95141
prometheus.GaugeValue,
96-
float64(as.Space.TotalPhysical)/float64(as.Capacity)*100,
142+
float64(*as.Space.TotalPhysical)/float64(as.Capacity)*100,
97143
t,
98144
)
99145
}

internal/openmetrics-exporter/buckets_space_collector.go

Lines changed: 88 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,94 @@ func (c *BucketsSpaceCollector) Collect(ch chan<- prometheus.Metric) {
2525
return
2626
}
2727
for _, bucket := range c.Buckets.Items {
28-
ch <- prometheus.MustNewConstMetric(
29-
c.ReductionDesc,
30-
prometheus.GaugeValue,
31-
float64(bucket.Space.DataReduction),
32-
bucket.Name, bucket.Account.Name,
33-
)
34-
ch <- prometheus.MustNewConstMetric(
35-
c.SpaceDesc,
36-
prometheus.GaugeValue,
37-
float64(bucket.Space.Snapshots),
38-
bucket.Name, bucket.Account.Name, "snapshots",
39-
)
40-
ch <- prometheus.MustNewConstMetric(
41-
c.SpaceDesc,
42-
prometheus.GaugeValue,
43-
float64(bucket.Space.TotalPhysical),
44-
bucket.Name, bucket.Account.Name, "total_physical",
45-
)
46-
ch <- prometheus.MustNewConstMetric(
47-
c.SpaceDesc,
48-
prometheus.GaugeValue,
49-
float64(bucket.Space.Unique),
50-
bucket.Name, bucket.Account.Name, "unique",
51-
)
52-
ch <- prometheus.MustNewConstMetric(
53-
c.SpaceDesc,
54-
prometheus.GaugeValue,
55-
float64(bucket.Space.Virtual),
56-
bucket.Name, bucket.Account.Name, "virtual",
57-
)
28+
if bucket.Space.DataReduction != nil {
29+
ch <- prometheus.MustNewConstMetric(
30+
c.ReductionDesc,
31+
prometheus.GaugeValue,
32+
float64(*bucket.Space.DataReduction),
33+
bucket.Name, bucket.Account.Name,
34+
)
35+
}
36+
if bucket.Space.Snapshots != nil {
37+
ch <- prometheus.MustNewConstMetric(
38+
c.SpaceDesc,
39+
prometheus.GaugeValue,
40+
float64(*bucket.Space.Snapshots),
41+
bucket.Name, bucket.Account.Name, "snapshots",
42+
)
43+
}
44+
if bucket.Space.TotalPhysical != nil {
45+
ch <- prometheus.MustNewConstMetric(
46+
c.SpaceDesc,
47+
prometheus.GaugeValue,
48+
float64(*bucket.Space.TotalPhysical),
49+
bucket.Name, bucket.Account.Name, "total_physical",
50+
)
51+
}
52+
if bucket.Space.Unique != nil {
53+
ch <- prometheus.MustNewConstMetric(
54+
c.SpaceDesc,
55+
prometheus.GaugeValue,
56+
float64(*bucket.Space.Unique),
57+
bucket.Name, bucket.Account.Name, "unique",
58+
)
59+
}
60+
if bucket.Space.Virtual != nil {
61+
ch <- prometheus.MustNewConstMetric(
62+
c.SpaceDesc,
63+
prometheus.GaugeValue,
64+
float64(*bucket.Space.Virtual),
65+
bucket.Name, bucket.Account.Name, "virtual",
66+
)
67+
}
68+
if bucket.Space.TotalProvisioned != nil {
69+
ch <- prometheus.MustNewConstMetric(
70+
c.SpaceDesc,
71+
prometheus.GaugeValue,
72+
float64(*bucket.Space.TotalProvisioned),
73+
bucket.Name, bucket.Account.Name, "total_provisioned",
74+
)
75+
}
76+
if bucket.Space.AvailableProvisioned != nil {
77+
ch <- prometheus.MustNewConstMetric(
78+
c.SpaceDesc,
79+
prometheus.GaugeValue,
80+
float64(*bucket.Space.AvailableProvisioned),
81+
bucket.Name, bucket.Account.Name, "available_provisioned",
82+
)
83+
}
84+
if bucket.Space.AvailableRatio != nil {
85+
ch <- prometheus.MustNewConstMetric(
86+
c.SpaceDesc,
87+
prometheus.GaugeValue,
88+
float64(*bucket.Space.AvailableRatio),
89+
bucket.Name, bucket.Account.Name, "available_ratio",
90+
)
91+
}
92+
if bucket.Space.Destroyed != nil {
93+
ch <- prometheus.MustNewConstMetric(
94+
c.SpaceDesc,
95+
prometheus.GaugeValue,
96+
float64(*bucket.Space.Destroyed),
97+
bucket.Name, bucket.Account.Name, "destroyed",
98+
)
99+
}
100+
if bucket.Space.DestroyedVirtual != nil {
101+
ch <- prometheus.MustNewConstMetric(
102+
c.SpaceDesc,
103+
prometheus.GaugeValue,
104+
float64(*bucket.Space.DestroyedVirtual),
105+
bucket.Name, bucket.Account.Name, "destroyed_virtual",
106+
)
107+
}
108+
if bucket.Space.Shared != nil {
109+
ch <- prometheus.MustNewConstMetric(
110+
c.SpaceDesc,
111+
prometheus.GaugeValue,
112+
float64(*bucket.Space.Shared),
113+
bucket.Name, bucket.Account.Name, "shared",
114+
)
115+
}
58116
ch <- prometheus.MustNewConstMetric(
59117
c.SpaceDesc,
60118
prometheus.GaugeValue,

internal/openmetrics-exporter/collector.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func Collector(ctx context.Context, metrics string, registry *prometheus.Registr
3232
alertsCollector := NewAlertsCollector(fbclient)
3333
hardwareCollector := NewHardwareCollector(fbclient)
3434
hwPerfConnectorsCollector := NewHwConnectorsPerfCollector(fbclient)
35+
objstoreacctsCollector := NewObjectStoreAccountsCollector(fbclient)
3536
registry.MustRegister(
3637
perfCollector,
3738
s3perfCollector,
@@ -47,6 +48,7 @@ func Collector(ctx context.Context, metrics string, registry *prometheus.Registr
4748
alertsCollector,
4849
hardwareCollector,
4950
hwPerfConnectorsCollector,
51+
objstoreacctsCollector,
5052
)
5153
}
5254
if metrics == "all" || metrics == "clients" {

0 commit comments

Comments
 (0)