Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-24

- **`UpsOnBattery` now pages on a short transfer.** On 2026-11-21 the UPS
ran on battery for 82 seconds, for distorted input, and nothing paged. The
rule was `upsSecondsOnBattery > 0` for 30 seconds, which needs two scrapes in
a row a minute apart. One scrape read 42 seconds, the alert went pending, and
the next read 0. It is now `max_over_time(upsSecondsOnBattery[2m]) > 30`
with no `for`, so any scrape that reads more than 30 seconds on battery
pages. A transfer that ends inside 30 seconds still does not, like the
1-second one on 2026-11-07. `ups.test.yaml` replays both.
`shut-down-on-the-ups.md` puts the outside limit for the rule firing at about
three and a quarter minutes. That is a scrape starting up to 90 seconds after
the cut, up to 45 seconds for it to finish, and up to 60 seconds to the next
evaluation. The page then goes out with no group wait. The runbook also
separates a rule that never fired from a page that was never delivered.
- **Correction to the 2026-11-23 entry on `mjolnir`'s eight silent days: the
card's event log gives the cause, and it is the move into the 32U rack
([#919](https://github.com/Gerrrt/HomeLab/issues/919)).** That entry said
Expand Down
19 changes: 16 additions & 3 deletions docs/runbooks/shut-down-on-the-ups.md
Original file line number Diff line number Diff line change
Expand Up @@ -1286,9 +1286,22 @@ halt.** Run `journalctl -u nut-monitor -b -1` on `trinity`. A secondary that
never logged in never saw the flag. Check 4b.5's `upsc -c` listing, and that
4b.1's pass is above its block.

**`UpsOnBattery` did not fire within a minute in 6.2.** The scrape is every 60
seconds and the rule waits 30, so two minutes is the outside limit. Past that,
the card is not reporting the transfer — plug back in and stop.
**`UpsOnBattery` did not fire within a minute in 6.2.** It fires on the first
scrape that reads more than 30 seconds on battery. That scrape starts at most
90 seconds after the cut, because scrapes are 60 seconds apart. It can take up
to 45 seconds to finish (the `snmp` job's `scrape_timeout`), and the next rule
evaluation follows within 60 seconds. So the rule fires at most about three
and a quarter minutes after the cut. Its route (`severity="critical"`,
`category="power"`) has `group_wait: 0s`, so the page goes out straight away.
Past that limit, tell the two failures apart before you blame the card:

- **Prometheus at `/alerts` shows `UpsOnBattery` firing, but no page
arrived.** The fault is in delivery. Check Alertmanager's `/#/alerts` and
`alertmanager_notifications_failed_total`. The card is fine, so carry on.
- **Prometheus never shows it firing.** Look at `upsSecondsOnBattery` in
Prometheus. If it stays 0 while the UPS beeps, the card is not reporting the
transfer — plug back in and stop. If `up{device="mjolnir"}` is 0, the
scrape is failing instead.

**A real cut later ended with a host stopping uncleanly anyway.** The sequence
outgrew the window. `SmartDriveUnsafeShutdownsGrowing` is what tells you.
Expand Down
9 changes: 7 additions & 2 deletions stacks/observability/prometheus/rules/ups.rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ groups:
interval: 60s
rules:
- alert: UpsOnBattery
expr: upsSecondsOnBattery > 0
for: 30s
# Any scrape that saw more than 30 s on battery pages, with no `for`.
# `> 0` for 30s needed two scrapes in a row, a minute apart, so the
# 82-second transfer of 2026-11-21 was read once (42 s), went pending
# and cleared without paging. The 2m window keeps that one reading
# firing for the next evaluation. A transfer that never reaches 30 s
# still does not page.
expr: max_over_time(upsSecondsOnBattery[2m]) > 30
labels:
component: power
severity: critical
Expand Down
39 changes: 37 additions & 2 deletions stacks/observability/prometheus/tests/ups.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ tests:

# --- The nine UPS rules untested until #843 -------------------------------

# UpsOnBattery: 120s on battery fires after its 30s `for`; a UPS on mains (0) beside
# it does not. Quiet at 1m, before the cut.
# UpsOnBattery: 120s on battery fires on the first scrape that reads it; a UPS
# on mains (0) beside it does not. Quiet at 1m, before the cut.
- interval: 1m
input_series:
- series: 'upsSecondsOnBattery{job="snmp",instance="10.0.99.10",device="mjolnir"}'
Expand Down Expand Up @@ -228,6 +228,41 @@ tests:
On battery for 2m 0s. Estimated runtime remaining is reported by
upsEstimatedMinutesRemaining.

# UpsOnBattery on a short transfer: 2026-11-21's 82 seconds on battery, read
# by one scrape at 42 s, pages on that scrape. The 1-second transfer of
# 2026-11-07 (read as 1) does not. Both are quiet again once the 2m window has
# passed the reading.
- interval: 1m
input_series:
- series: 'upsSecondsOnBattery{job="snmp",instance="10.0.99.10",device="mjolnir"}'
values: "0 0 42 0 0 0 0 0"
- series: 'upsSecondsOnBattery{job="snmp",instance="10.0.99.11",device="spare"}'
values: "0 0 1 0 0 0 0 0"
alert_rule_test:
- eval_time: 1m
alertname: UpsOnBattery
exp_alerts: []
- eval_time: 2m
alertname: UpsOnBattery
exp_alerts:
- exp_labels:
alertname: UpsOnBattery
job: snmp
instance: 10.0.99.10
device: mjolnir
component: power
severity: critical
category: power
exp_annotations:
runbook_url: "https://github.com/Gerrrt/HomeLab/blob/main/docs/runbooks/shut-down-on-the-ups.md"
summary: "UPS mjolnir is running on battery"
description: >-
On battery for 42s. Estimated runtime remaining is reported by
upsEstimatedMinutesRemaining.
- eval_time: 5m
alertname: UpsOnBattery
exp_alerts: []

# UpsBatteryLow: batteryLow(3) fires; batteryNormal(2) is the near miss the `> 2`
# exists for.
- interval: 1m
Expand Down