Skip to content

Commit 2720965

Browse files
committed
Update metrics to be counters where appropriate
Signed-off-by: Mike Eves <[email protected]>
1 parent 6cb3e19 commit 2720965

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,20 @@ Further Information
224224
| elasticsearch_clusterinfo_up | gauge | 1 | Up metric for the cluster info collector
225225
| elasticsearch_clusterinfo_version_info | gauge | 6 | Constant metric with ES version information as labels
226226
| elasticsearch_slm_stats_up | gauge | 0 | Up metric for SLM collector
227-
| elasticsearch_slm_stats_total_scrapes | gauge | 0 | Number of scrapes for SLM collector
228-
| elasticsearch_slm_stats_json_parse_failures | gauge | 0 | JSON parse failures for SLM collector
229-
| elasticsearch_slm_stats_retention_runs | gauge | 0 | Total retention runs
230-
| elasticsearch_slm_stats_retention_failed | gauge | 0 | Total failed retention runs
231-
| elasticsearch_slm_stats_retention_timed_out | gauge | 0 | Total retention run timeouts
232-
| elasticsearch_slm_stats_retention_retention_deletion_time_millis | gauge | 0 | Retention run deletion time
233-
| elasticsearch_slm_stats_total_snapshots_taken | gauge | 0 | Total snapshots taken
234-
| elasticsearch_slm_stats_total_snapshots_failed | gauge | 0 | Total snapshots failed
235-
| elasticsearch_slm_stats_total_snapshots_deleted | gauge | 0 | Total snapshots deleted
236-
| elasticsearch_slm_stats_total_snapshots_failed | gauge | 0 | Total snapshots failed
237-
| elasticsearch_slm_stats_snapshots_taken | gauge | 1 | Snapshots taken by policy
238-
| elasticsearch_slm_stats_snapshots_failed | gauge | 1 | Snapshots failed by policy
239-
| elasticsearch_slm_stats_snapshots_deleted | gauge | 1 | Snapshots deleted by policy
240-
| elasticsearch_slm_stats_snapshot_deletion_failures | gauge | 1 | Snapshot deletion failures by policy
227+
| elasticsearch_slm_stats_total_scrapes | counter | 0 | Number of scrapes for SLM collector
228+
| elasticsearch_slm_stats_json_parse_failures | counter | 0 | JSON parse failures for SLM collector
229+
| elasticsearch_slm_stats_retention_runs_total | counter | 0 | Total retention runs
230+
| elasticsearch_slm_stats_retention_failed_total | counter | 0 | Total failed retention runs
231+
| elasticsearch_slm_stats_retention_timed_out_total | counter | 0 | Total retention run timeouts
232+
| elasticsearch_slm_stats_retention_deletion_time_seconds | gauge | 0 | Retention run deletion time
233+
| elasticsearch_slm_stats_total_snapshots_taken_total | counter | 0 | Total snapshots taken
234+
| elasticsearch_slm_stats_total_snapshots_failed_total | counter | 0 | Total snapshots failed
235+
| elasticsearch_slm_stats_total_snapshots_deleted_total | counter | 0 | Total snapshots deleted
236+
| elasticsearch_slm_stats_total_snapshots_failed_total | counter | 0 | Total snapshots failed
237+
| elasticsearch_slm_stats_snapshots_taken_total | counter | 1 | Snapshots taken by policy
238+
| elasticsearch_slm_stats_snapshots_failed_total | counter | 1 | Snapshots failed by policy
239+
| elasticsearch_slm_stats_snapshots_deleted_total | counter | 1 | Snapshots deleted by policy
240+
| elasticsearch_slm_stats_snapshot_deletion_failures_total | counter | 1 | Snapshot deletion failures by policy
241241
| elasticsearch_slm_stats_operation_mode | gauge | 1 | SLM operation mode (Running, stopping, stopped)
242242

243243

collector/slm.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
9090
}),
9191
slmMetrics: []*slmMetric{
9292
{
93-
Type: prometheus.GaugeValue,
93+
Type: prometheus.CounterValue,
9494
Desc: prometheus.NewDesc(
95-
prometheus.BuildFQName(namespace, "slm_stats", "retention_runs"),
95+
prometheus.BuildFQName(namespace, "slm_stats", "retention_runs_total"),
9696
"Total retention runs",
9797
nil, nil,
9898
),
@@ -101,9 +101,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
101101
},
102102
},
103103
{
104-
Type: prometheus.GaugeValue,
104+
Type: prometheus.CounterValue,
105105
Desc: prometheus.NewDesc(
106-
prometheus.BuildFQName(namespace, "slm_stats", "retention_failed"),
106+
prometheus.BuildFQName(namespace, "slm_stats", "retention_failed_total"),
107107
"Total failed retention runs",
108108
nil, nil,
109109
),
@@ -112,9 +112,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
112112
},
113113
},
114114
{
115-
Type: prometheus.GaugeValue,
115+
Type: prometheus.CounterValue,
116116
Desc: prometheus.NewDesc(
117-
prometheus.BuildFQName(namespace, "slm_stats", "retention_timed_out"),
117+
prometheus.BuildFQName(namespace, "slm_stats", "retention_timed_out_total"),
118118
"Total timed out retention runs",
119119
nil, nil,
120120
),
@@ -134,9 +134,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
134134
},
135135
},
136136
{
137-
Type: prometheus.GaugeValue,
137+
Type: prometheus.CounterValue,
138138
Desc: prometheus.NewDesc(
139-
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshots_taken"),
139+
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshots_taken_total"),
140140
"Total snapshots taken",
141141
nil, nil,
142142
),
@@ -145,9 +145,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
145145
},
146146
},
147147
{
148-
Type: prometheus.GaugeValue,
148+
Type: prometheus.CounterValue,
149149
Desc: prometheus.NewDesc(
150-
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshots_failed"),
150+
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshots_failed_total"),
151151
"Total snapshots failed",
152152
nil, nil,
153153
),
@@ -156,9 +156,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
156156
},
157157
},
158158
{
159-
Type: prometheus.GaugeValue,
159+
Type: prometheus.CounterValue,
160160
Desc: prometheus.NewDesc(
161-
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshots_deleted"),
161+
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshots_deleted_total"),
162162
"Total snapshots deleted",
163163
nil, nil,
164164
),
@@ -167,9 +167,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
167167
},
168168
},
169169
{
170-
Type: prometheus.GaugeValue,
170+
Type: prometheus.CounterValue,
171171
Desc: prometheus.NewDesc(
172-
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshot_deletion_failures"),
172+
prometheus.BuildFQName(namespace, "slm_stats", "total_snapshot_deletion_failures_total"),
173173
"Total snapshot deletion failures",
174174
nil, nil,
175175
),
@@ -180,9 +180,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
180180
},
181181
policyMetrics: []*policyMetric{
182182
{
183-
Type: prometheus.GaugeValue,
183+
Type: prometheus.CounterValue,
184184
Desc: prometheus.NewDesc(
185-
prometheus.BuildFQName(namespace, "slm_stats", "snapshots_taken"),
185+
prometheus.BuildFQName(namespace, "slm_stats", "snapshots_taken_total"),
186186
"Total snapshots taken",
187187
defaultPolicyLabels, nil,
188188
),
@@ -192,9 +192,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
192192
Labels: defaultPolicyLabelValues,
193193
},
194194
{
195-
Type: prometheus.GaugeValue,
195+
Type: prometheus.CounterValue,
196196
Desc: prometheus.NewDesc(
197-
prometheus.BuildFQName(namespace, "slm_stats", "snapshots_failed"),
197+
prometheus.BuildFQName(namespace, "slm_stats", "snapshots_failed_total"),
198198
"Total snapshots failed",
199199
defaultPolicyLabels, nil,
200200
),
@@ -204,9 +204,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
204204
Labels: defaultPolicyLabelValues,
205205
},
206206
{
207-
Type: prometheus.GaugeValue,
207+
Type: prometheus.CounterValue,
208208
Desc: prometheus.NewDesc(
209-
prometheus.BuildFQName(namespace, "slm_stats", "snapshots_deleted"),
209+
prometheus.BuildFQName(namespace, "slm_stats", "snapshots_deleted_total"),
210210
"Total snapshots deleted",
211211
defaultPolicyLabels, nil,
212212
),
@@ -216,9 +216,9 @@ func NewSLM(logger log.Logger, client *http.Client, url *url.URL) *SLM {
216216
Labels: defaultPolicyLabelValues,
217217
},
218218
{
219-
Type: prometheus.GaugeValue,
219+
Type: prometheus.CounterValue,
220220
Desc: prometheus.NewDesc(
221-
prometheus.BuildFQName(namespace, "slm_stats", "snapshot_deletion_failures"),
221+
prometheus.BuildFQName(namespace, "slm_stats", "snapshot_deletion_failures_total"),
222222
"Total snapshot deletion failures",
223223
defaultPolicyLabels, nil,
224224
),

0 commit comments

Comments
 (0)