@@ -32,6 +32,7 @@ type exporter struct {
32
32
33
33
info * prometheus.Desc
34
34
count * prometheus.Desc
35
+ ds * prometheus.Desc
35
36
size * prometheus.Desc
36
37
dur * prometheus.Desc
37
38
suc * prometheus.Desc
@@ -63,6 +64,11 @@ func registerExporter(ctx context.Context, providers []unused.Provider, cfg conf
63
64
"How many unused disks are in this provider" ,
64
65
append (labels , "k8s_namespace" ),
65
66
nil ),
67
+ ds : prometheus .NewDesc (
68
+ prometheus .BuildFQName (namespace , "disk" , "size_bytes" ),
69
+ "Disk size in bytes" ,
70
+ append (labels , []string {"disk" , "k8s_namespace" , "type" , "region" , "zone" }... ),
71
+ nil ),
66
72
67
73
size : prometheus .NewDesc (
68
74
prometheus .BuildFQName (namespace , "disks" , "size_gb" ),
@@ -177,6 +183,7 @@ func (e *exporter) pollProvider(p unused.Provider) {
177
183
}
178
184
179
185
addMetric (& ms , p , e .dlu , lastUsedTS (d ), d .ID (), m .CreatedForPV (), m .CreatedForPVC (), m .Zone ())
186
+ addMetric (& ms , p , e .ds , d .SizeBytes (), d .ID (), ns , string (d .DiskType ()), getRegionFromZone (p , m .Zone ()), m .Zone ())
180
187
}
181
188
182
189
addMetric (& ms , p , e .info , 1 )
@@ -277,3 +284,12 @@ func lastUsedTS(d unused.Disk) float64 {
277
284
278
285
return float64 (lastUsed .UnixMilli ())
279
286
}
287
+
288
+ func getRegionFromZone (p unused.Provider , z string ) string {
289
+ if strings .ToLower (p .Name ()) == "azure" {
290
+ return z
291
+ }
292
+
293
+ // Drop the last character to get the region from the zone for GCP and AWS
294
+ return z [:len (z )- 1 ]
295
+ }
0 commit comments