From 4e2c7e1d6e084645c073d8a55fd0574769e3803b Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Tue, 19 Nov 2024 18:09:52 +0100 Subject: [PATCH] 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 --- nvme_metrics.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/nvme_metrics.py b/nvme_metrics.py index f6e3a6c..f148750 100755 --- a/nvme_metrics.py +++ b/nvme_metrics.py @@ -34,6 +34,12 @@ "Device controller busy time in seconds", ["device"], namespace=namespace, registry=registry, ), + "controller_info": Info( + "controller", + "Controller information", + ["controller", "model", "firmware", "serial", "transport"], namespace=namespace, + registry=registry, + ), "critical_warning": Gauge( "critical_warning", "Device critical warning bitmap field", @@ -49,11 +55,6 @@ "Number of 512-byte data units written by host, reported in thousands", ["device"], namespace=namespace, registry=registry, ), - "device_info": Info( - "device", - "Device information", - ["device", "model", "firmware", "serial"], namespace=namespace, registry=registry, - ), "host_read_commands": Counter( "host_read_commands_total", "Device read commands from host", @@ -163,20 +164,17 @@ def main(): for device in device_list["Devices"]: for subsys in device["Subsystems"]: for ctrl in subsys["Controllers"]: + metrics["controller_info"].labels( + ctrl["Controller"], + ctrl["ModelNumber"], + ctrl["Firmware"], + ctrl["SerialNumber"].strip(), + ctrl["Transport"], + ) + for ns in ctrl["Namespaces"]: device_name = ns["NameSpace"] - # FIXME: This metric ought to be refactored into a "controller_info" metric, - # since it contains information that is not unique to the namespace. However, - # previous versions of this collector erroneously referred to namespaces, e.g. - # "nvme0n1", as devices, so preserve the former behaviour for now. - metrics["device_info"].labels( - device_name, - ctrl["ModelNumber"], - ctrl["Firmware"], - ctrl["SerialNumber"].strip(), - ) - metrics["sector_size"].labels(device_name).set(ns["SectorSize"]) metrics["physical_size"].labels(device_name).set(ns["PhysicalSize"]) metrics["used_bytes"].labels(device_name).set(ns["UsedBytes"])