Skip to content

Add: NOTIFY_LEVEL and NOTIFY_FORMAT for more control over notifications - #139

Open
databloat wants to merge 2 commits into
containrrr:masterfrom
databloat:add-notification-options
Open

databloat wants to merge 2 commits into
containrrr:masterfrom
databloat:add-notification-options

Conversation

@databloat

Copy link
Copy Markdown

What i changed

  • Added NOTIFY_LEVEL to optionally notify on every check, including up_to_date
  • Added NOTIFY_FORMAT=JSON for structured webhook payloads
  • Simplified send_notification() to work with structured data

Why

Currently, notifications are only sent when an update succeeds or fails. This means downstream processes can't distinguish between a service that was never checked and one that was checked and is already up to date.

JSON output also makes it easier for downstream systems like Zabbix to process the events without parsing human-readable text.

Both options are opt-in, so the default behavior stays unchanged.

I tested all four event types (image_missing, update_failed, updated, up_to_date) in both default and JSON mode.

Also verified that the default output remains unchanged and tested the JSON output with a standalone docker swarm and a custom Zabbix receiver acting as an Apprise upstream service.

Cheers

Currently a notification (via APPRISE_SIDECAR_URL) is only sent when a
service update succeeds or fails. If a service is skipped because no
update is available, nothing is sent - so a consumer of the webhook
(e.g. a monitoring system) can't distinguish "never checked" from
"checked, nothing to do" from "still broken since the last failure".

Add an opt-in NOTIFY_LEVEL variable:
- UPDATE (default): current behavior, unchanged
- ALL: also send a "success" notification when a service is checked
  but does not need an update

Fully backwards compatible - default behavior is identical.
…se-shaped payloads

send_notification() currently always posts an Apprise-shaped payload
({"title", "body", "notify_type"}) to APPRISE_SIDECAR_URL. That's a
good fit for actual notification services, but awkward for anything
that wants to programmatically consume these events (monitoring
systems, custom webhook receivers): the service name and event type
are embedded in free-text title/body strings that have to be parsed
back out.

Add an opt-in NOTIFY_FORMAT variable (paired with NOTIFY_LEVEL - both
prefixed NOTIFY_ since they configure the same notification pipeline):
- DEFAULT (default): current Apprise-shaped behavior, byte-for-byte
  identical title/body text to before
- JSON: sends a flat, structured payload instead:
  {"service", "event", "status", "hostname", "timestamp", "message"},
  where "event" is one of image_missing/update_failed/updated/up_to_date

Refactored send_notification() to take structured arguments (service
name, event, status, detail message) instead of pre-built title/body
strings, and builds either shape from those depending on NOTIFY_FORMAT.
As a side effect this also removes the repeated title/body/$(date)
construction at each call site.

Fully backwards compatible - default behavior and payload shape are
unchanged.
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