Skip to content

Commit

Permalink
nvme_metrics: introduce nvme_namespace_info metric
Browse files Browse the repository at this point in the history
Introduce info metric to facilitate join-relationship between
namespace-specific and controller-specific metrics.

e.g. nvme_namespace_info{controller="nvme0",namepace="nvme0n1",nsid="1"}

Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
  • Loading branch information
dswarbrick committed Nov 21, 2024
1 parent da956a5 commit 895fbb1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions nvme_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
),

# Namespace-specific (e.g. "nvme0n1") metrics
"namespace_info": Info(
"namespace",
"Namespace information",
["namepace", "nsid", "controller"], namespace=namespace, registry=registry,
),
"physical_size": Gauge(
"physical_size_bytes",
"Device size in bytes",
Expand Down Expand Up @@ -179,11 +184,17 @@ def main():
)

for ns in ctrl["Namespaces"]:
device_name = ns["NameSpace"]
ns_dev = ns["NameSpace"]

metrics["namespace_info"].labels(
ns_dev,
ns["NSID"],
ctrl_dev,
)

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"])
metrics["sector_size"].labels(ns_dev).set(ns["SectorSize"])
metrics["physical_size"].labels(ns_dev).set(ns["PhysicalSize"])
metrics["used_bytes"].labels(ns_dev).set(ns["UsedBytes"])

# Most SSDs (perhaps _all_ consumer grade SSDs) only contain a single namespace.
# Fetch the device global SMART log by omitting any --namespace-id flag.
Expand Down

0 comments on commit 895fbb1

Please sign in to comment.