Skip to content

os: add windows_os_reboot_required metric - #2871

Merged
jkroepke merged 2 commits into
mainfrom
claude/project-thread-y7z7i4
Dec 3, 2026
Merged

jkroepke merged 2 commits into
mainfrom
claude/project-thread-y7z7i4

Conversation

@jkroepke

@jkroepke jkroepke commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Requested by Joe · project thread

What this PR does / why we need it

Adds windows_os_reboot_required{reason} (gauge, 0/1) to the os collector. It reads the registry locations Windows uses to record a pending reboot, one series per reason:

reason Source
component_servicing key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending exists
windows_update key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired exists
file_rename PendingFileRenameOperations / PendingFileRenameOperations2 under Session Manager is non-empty
computer_rename ComputerName\ComputerName differs from ComputerName\ActiveComputerName

Most other Windows agents ship this check (NSClient++ check_pending_reboot, Zabbix and Datadog templates, the usual PowerShell pending-reboot scripts). The registry collector can't express it: it reads values, but cannot test whether a key exists or compare two values.

file_rename is kept as its own reason because installers and antivirus set it often; the documented query and alert example leave it out.

Which issue this PR fixes

None open. Older requests were closed as stale.

Special notes for your reviewer

  • Six registry reads per scrape, no new dependencies or flags.
  • A reason whose location the exporter's account may not read (access denied) is left out with a warning logged once, so a restricted ACL can't fail every scrape of the default os collector. Any other read error leaves the reason out and is joined into the collector error; the other reasons are still published. I expect all locations to be readable by BUILTIN\Users (and so by the service's virtual account), but haven't verified that on a live host.
  • The collector test checks the type, labels and the four reasons; the Windows tests run in CI only.
  • windows_update is a label value, so it is added to ignoredReferences in internal/metriccontract.
  • No mixin alert in this PR to keep it small; docs/collector.os.md has a query and an alert example. A mixin alert with runbook can follow.

This PR was written in part with the assistance of generative AI.

Particularly user-facing changes

New metric windows_os_reboot_required{reason}.

Checklist

  • DCO signed
  • The PR title has a summary of the changes and the area they affect
  • The PR body has a summary to reflect any significant (and particularly user-facing) changes introduced by this PR

Generated by Claude Code

Read the registry locations that Windows uses to record a pending
reboot and expose one series per reason: component based servicing,
Windows Update, pending file rename operations and a pending computer
rename. The registry collector can only read values, not test whether
a key exists or compare two values.

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
@jkroepke jkroepke added the ✨ enhancement label Dec 2, 2026 — with Claude
@jkroepke jkroepke self-assigned this Dec 2, 2026
Leave a reason out with a warning when the exporter's account may not
read its registry location, so a restricted ACL doesn't fail every
scrape. Count a rename list of an unexpected type as pending. Check the
emitted series in the collector test.

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
@jkroepke
jkroepke marked this pull request as ready for review December 3, 2026 20:28
@jkroepke
jkroepke requested a review from a team as a code owner December 3, 2026 20:28

@Dominik-esb Dominik-esb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on my test system

@jkroepke
jkroepke merged commit 9f93cec into main Dec 3, 2026
18 of 19 checks passed
@jkroepke
jkroepke deleted the claude/project-thread-y7z7i4 branch December 3, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants