Skip to content

Commit

Permalink
nvme_metrics: refactor device_info metric as controller_info
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dswarbrick committed Nov 19, 2024
1 parent e016bbb commit 4e2c7e1
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions nvme_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit 4e2c7e1

Please sign in to comment.