sensor-monitor: add per-rule snooze DoCommand#11
Open
Nicolas Palpacuer (NickPPC) wants to merge 1 commit into
Open
sensor-monitor: add per-rule snooze DoCommand#11Nicolas Palpacuer (NickPPC) wants to merge 1 commit into
Nicolas Palpacuer (NickPPC) wants to merge 1 commit into
Conversation
Add a "snooze" DoCommand that suppresses evaluation of a single named
rule for a duration: {"snooze": {"rule_name": <name>, "duration": <dur>}}.
Duration is a string with a seconds/minutes/hours/days unit (e.g. "30s",
"90m", "24h", "5d") — a custom parser is used because time.ParseDuration
does not support a "d" unit.
Rules gain an optional unique "name" so they can be targeted; snooze state
is tracked per rule, so snoozing one rule leaves the others evaluating.
While snoozed a rule is not evaluated and its actions do not fire, but
readings stay current and its state is frozen, so a condition still
breaching when the snooze ends fires on the next poll. Readings expose
"<key>_snoozed" per rule alongside the existing "<key>_triggered".
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
snoozeDoCommand to thesensor-monitormodel that temporarily suppresses a single rule's evaluation. This lets an operator silence a specific alert (e.g. during known maintenance) without disabling the whole monitor or the other rules.Changes
{"snooze": {"rule_name": <name>, "duration": <dur>}}DoCommand that suppresses evaluation of one named rule until the duration elapses. Returns{"rule_name", "snoozed_until"}(RFC 3339).namefield to rules so they can be targeted by snooze;Validaterejects duplicate names. Only named rules can be snoozed.ruleState.snoozeUntil).pollskips only snoozed rules — others keep evaluating, readings stay current, and a rule's state is frozen while snoozed so a condition still breaching when the snooze ends fires on the next poll.parseSnoozeDurationsupportings/m/h/dunits (e.g.30s,90m,24h,5d), becausetime.ParseDurationhas nod(day) unit.Readingsnow exposes<key>_snoozedper rule alongside the existing<key>_triggered.namerule field, thesnoozeDoCommand payload/response, and the new per-rule_snoozedreading.Testing
go build ./...,go vet ./..., andgo test ./...all pass (package coverage 85.3%).TestParseSnoozeDuration— all four units, decimals, case/whitespace handling, and invalid inputs (missing unit, unsupported unit, negative).TestDoCommandSnoozeSuppressesRule— two rules; snoozing one keeps it silent while the other still fires, verifies per-rule_snoozedreadings, and confirms firing resumes after the snooze expires.TestDoCommandSnoozeInvalid— non-object payload, missing/empty/unknownrule_name, and missing/non-string/invalidduration.TestValidate— added a duplicate-rule-names case.Notes
namecannot be snoozed.namewas kept optional to avoid breaking existing configs.Claude Code Prompts Used
🤖 Generated with Claude Code