Skip to content

feat(metrics): alert on failed snapshot - #39

Merged
DavidePrincipi merged 6 commits into
mainfrom
feat-snapshot-alert
Nov 24, 2026
Merged

DavidePrincipi merged 6 commits into
mainfrom
feat-snapshot-alert

Conversation

@DavidePrincipi

@DavidePrincipi DavidePrincipi commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

When the weekly snapshot job fails, or does not run, nobody is notified: no new snapshot is created, and later edits with edit-repodata go into an older snapshot that all clients receive. This happened recently and went unnoticed for days. See https://mattermost.nethesis.it/nethesis/pl/eiqcyqsddbb5ucdttfqabfxbdh

The module now reports whether snapshot.service failed and how old the latest snapshot is, and ships alert rules for both. The core and the metrics module do the rest: they collect the value, evaluate the rule, and send the alert by mail and to my.nethesis.it.

  • bin/export-metrics prints porthos_snapshot_failed, 1 when the service is failed, and the creation time of the latest snapshot.
  • PorthosSnapshotFailed (critical) fires when the service is failed for 1 hour.
  • PorthosSnapshotTooOld fires when the latest snapshot is older than 1 week (info), 2 weeks (warning) or 3 weeks (critical).
  • The rules are published by configure-module, which starts the snapshot services, and again when a configured module is updated.

How to test

  1. Install and configure the module, or update it, on a node with core 3.24.0 and metrics 1.7.0 or later.
  2. Make the snapshot fail, e.g. with a wrong PORTHOS_SOURCE, and run runagent -m porthos1 systemctl --user start snapshot.service.
  3. After about 1 hour, the PorthosSnapshotFailed alert is firing in Prometheus.
  4. Reset the service with runagent -m porthos1 systemctl --user reset-failed snapshot.service: the alert is resolved.
  5. Rename the latest snapshot to make it 8, 15 or 22 days old: after 1 hour PorthosSnapshotTooOld fires with severity info, warning or critical.

Generated by Claude Code:claude-opus-5-5 with nethserver-pr

A failed snapshot.service went unnoticed: no new snapshot was created
and later repodata edits went into an older snapshot, served to all
client tiers.

Export the porthos_snapshot_failed metric with the core export-metrics
command, and publish the PorthosSnapshotFailed alert rule for the
metrics module when the module is installed or updated.

Assisted-by: Claude Code:claude-opus-5-5
@DavidePrincipi DavidePrincipi self-assigned this Nov 24, 2026
A snapshot that is not renewed keeps clients without new updates, also
when snapshot.service does not fail, e.g. if its timer does not run.

Export the creation time of the latest snapshot and publish the
PorthosSnapshotTooOld alert, whose severity grows with the snapshot
age: info after 1 week, warning after 2, critical after 3.

Assisted-by: Claude Code:claude-opus-5-5
The snapshot services start with configure-module: publish the alert
rules from there, so a module that is only installed raises no alert.
On update, publish them only if the module was configured.

The module bin directory is in the agent PATH: call the command by
name.

Assisted-by: Claude Code:claude-opus-5-5
Read the latest snapshot name in the fpm container, which mounts the
webroot volume at a known path, instead of resolving the volume path
on the host.

Assisted-by: Claude Code:claude-opus-5-5
Compute the latest snapshot timestamp in the fpm container too, with
the same PHP parsing of snapshot.php, instead of mixing it with Bash.

Assisted-by: Claude Code:claude-opus-5-5
A failed snapshot needs no immediate action: wait 1 hour before firing
PorthosSnapshotFailed, like the snapshot age alerts. Remove the version
requirements from the README.

Assisted-by: Claude Code:claude-opus-5-5
@DavidePrincipi
DavidePrincipi marked this pull request as ready for review November 24, 2026 18:01
@DavidePrincipi
DavidePrincipi merged commit 1ab8183 into main Nov 24, 2026
5 checks passed
@DavidePrincipi
DavidePrincipi deleted the feat-snapshot-alert branch November 24, 2026 19:04
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