Skip to content

Add NVMe warning and critical temperature time metrics - #423

Open
jhoblitt wants to merge 1 commit into
prometheus-community:masterfrom
jhoblitt:nvme-temperature-time
Open

jhoblitt wants to merge 1 commit into
prometheus-community:masterfrom
jhoblitt:nvme-temperature-time

Conversation

@jhoblitt

Copy link
Copy Markdown

Motivation

An NVMe drive records how long its composite temperature has been at or above its warning and critical thresholds. A point-in-time temperature gauge misses excursions between scrapes, and these fields were asked for in #272.

What changed

smartctl_device_warning_temperature_seconds_total and smartctl_device_critical_temperature_seconds_total for NVMe devices, from warning_temp_time / critical_comp_time (minutes, converted to seconds). No new smartctl arguments.

Notable decisions

unsafe_shutdowns is left out, following the discussion in #272.


This PR was prepared with an AI coding assistant (Claude Code) at my direction; I own it.

Export the Warning Composite Temperature Time and Critical Composite
Temperature Time fields of the NVMe SMART / Health Information log as
smartctl_device_warning_temperature_seconds_total and
smartctl_device_critical_temperature_seconds_total.

The device keeps these as cumulative counts of whole minutes during
which its composite temperature was at or above its warning (WCTEMP)
and critical (CCTEMP) thresholds. Unlike the point-in-time temperature
gauge they show overheating that happened between scrapes. Values are
converted to seconds and exposed as counters labelled by device like
the other NVMe metrics, only for NVMe devices. Because the device
reports whole minutes, rate() moves in 60 s steps. These are
time-above-threshold counters, not the thermal management throttling
counters, which smartctl only prints as text.

smartctl reports the fields as warning_temp_time and critical_comp_time
in nvme_smart_health_information_log since JSON output was introduced
in 7.0, and --attributes already requests the log. smartctl omits a
field when both its value and the controller's matching threshold
(WCTEMP/CCTEMP) are zero, so the metric is only exported when the field
is present and a series may first appear with a non-zero value.

The two fields were requested in
prometheus-community#272. unsafe_shutdowns, also
asked for there, is not exported: a maintainer noted in that issue that
it effectively counts host shutdowns, so it carries little drive-health
signal.

The tests use github.com/prometheus/client_golang/prometheus/testutil,
which adds the github.com/kylelemons/godebug indirect line to go.mod.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
@jhoblitt
jhoblitt marked this pull request as ready for review November 30, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant