Skip to content

Commit 4e2c7e1

Browse files
committed
nvme_metrics: refactor device_info metric as controller_info
This is a breaking change, as it renames the existing metric nvme_device_info to nvme_controller_info. The previous "device" label is now "controller", and takes the form of e.g. "nvme0" instead of "nvme0n1". A new label "transport" is also added to the renamed metric. Signed-off-by: Daniel Swarbrick <[email protected]>
1 parent e016bbb commit 4e2c7e1

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

nvme_metrics.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
"Device controller busy time in seconds",
3535
["device"], namespace=namespace, registry=registry,
3636
),
37+
"controller_info": Info(
38+
"controller",
39+
"Controller information",
40+
["controller", "model", "firmware", "serial", "transport"], namespace=namespace,
41+
registry=registry,
42+
),
3743
"critical_warning": Gauge(
3844
"critical_warning",
3945
"Device critical warning bitmap field",
@@ -49,11 +55,6 @@
4955
"Number of 512-byte data units written by host, reported in thousands",
5056
["device"], namespace=namespace, registry=registry,
5157
),
52-
"device_info": Info(
53-
"device",
54-
"Device information",
55-
["device", "model", "firmware", "serial"], namespace=namespace, registry=registry,
56-
),
5758
"host_read_commands": Counter(
5859
"host_read_commands_total",
5960
"Device read commands from host",
@@ -163,20 +164,17 @@ def main():
163164
for device in device_list["Devices"]:
164165
for subsys in device["Subsystems"]:
165166
for ctrl in subsys["Controllers"]:
167+
metrics["controller_info"].labels(
168+
ctrl["Controller"],
169+
ctrl["ModelNumber"],
170+
ctrl["Firmware"],
171+
ctrl["SerialNumber"].strip(),
172+
ctrl["Transport"],
173+
)
174+
166175
for ns in ctrl["Namespaces"]:
167176
device_name = ns["NameSpace"]
168177

169-
# FIXME: This metric ought to be refactored into a "controller_info" metric,
170-
# since it contains information that is not unique to the namespace. However,
171-
# previous versions of this collector erroneously referred to namespaces, e.g.
172-
# "nvme0n1", as devices, so preserve the former behaviour for now.
173-
metrics["device_info"].labels(
174-
device_name,
175-
ctrl["ModelNumber"],
176-
ctrl["Firmware"],
177-
ctrl["SerialNumber"].strip(),
178-
)
179-
180178
metrics["sector_size"].labels(device_name).set(ns["SectorSize"])
181179
metrics["physical_size"].labels(device_name).set(ns["PhysicalSize"])
182180
metrics["used_bytes"].labels(device_name).set(ns["UsedBytes"])

0 commit comments

Comments
 (0)