Sign inSign up

pasinduakalpa/komodo-ntfy-rs

By pasinduakalpa

•Updated 8 days ago

A Komodo Alerter endpoint that forwards alerts to ntfy.

Image
Networking
Integration & delivery
0

137

pasinduakalpa/komodo-ntfy-rs repository overview

⁠komodo-ntfy-rs

A Komodo⁠ Alerter⁠ endpoint that forwards alerts to ntfy⁠.

A Rust (axum⁠) port of the Deno komodo-utilities ntfy notifier⁠. It uses the same environment variables, so it works as a drop-in replacement.

⁠How it works

Komodo POSTs each alert as JSON to http://<host>:7000/. The alert is turned into a notification and published to your ntfy topic:

Komodo alertntfy notification
level: WARNING, ServerCpu on srv at 91.6%[WARNING] ServerCpu for srv: Hit 92% (priority 4)
level: OK, resolved ServerMem[OK] ServerMem for srv on host: ✅ Used 1,234.5/2,048GB (priority 3)

The endpoint always replies 200. Push failures are logged with ntfy's response so they can be diagnosed (see Troubleshooting⁠).

⁠Quick start

⁠Docker Compose
services:
  komodo-ntfy:
    image: pasinduakalpa/komodo-ntfy-rs:latest
    restart: unless-stopped
    env_file: .env

Copy .env.example⁠ to .env, then set at least NTFY_URL and NTFY_TOPIC.

⁠Komodo

Create an Alerter in Komodo:

  • Endpoint: Custom
  • URL: http://komodo-ntfy:7000. Use the service name if it's on the same Docker network as Komodo Core; otherwise use the host and port.

Press Test Alerter in Komodo. A [OK] Test for <alerter name> notification should arrive in ntfy.

⁠Configuration

All settings are environment variables. See .env.example⁠ for full descriptions.

VariableDefaultDescription
NTFY_URLrequiredntfy server base URL
NTFY_TOPICrequiredTopic to publish to
NTFY_USER / NTFY_PASSWORD–Basic auth (wins over token)
NTFY_TOKEN–Access token, sent as Bearer
NTFY_OK_PRIORITY3ntfy priority for OK
NTFY_WARNING_PRIORITY4ntfy priority for WARNING
NTFY_CRITICAL_PRIORITY5ntfy priority for CRITICAL
LEVEL_IN_TITLEtruePrefix the title with [LEVEL]
INDICATE_RESOLVEDtruePrefix resolved alerts with ✅
ALLOW_RESOLVED_TYPEbothresolved, unresolved, or both
UNRESOLVED_TIMEOUT–Hold unresolved alerts for N ms; skip both if resolved in time
UNRESOLVED_TIMEOUT_TYPESallAlert types the timeout applies to
PORT7000Listen port

⁠Troubleshooting

When a push fails, the log shows ntfy's HTTP status and response body:

LogMeaning
HTTP 401 ... "code":40101Wrong username/password or token
HTTP 403 ... "code":40301ntfy treated the request as anonymous or as a user without write access to the topic
HTTP 403 cf-mitigated=challenge cf-ray=...Cloudflare challenged the request (a server can't solve it). Look up the ray in Cloudflare Security → Events to see which rule fired, then skip it for the ntfy host, or point NTFY_URL at ntfy's internal address
HTTP 403 with another HTML bodySome other proxy in front of ntfy blocked the request
error sending requestntfy is unreachable (DNS, network, TLS)

To check from the Docker host:

curl -i -H "Authorization: Bearer $NTFY_TOKEN" -d test "$NTFY_URL/$NTFY_TOPIC"

⁠Development

Requires Rust 1.99 (pinned in mise.toml).

cargo test                                  # unit + integration tests (uses a fake ntfy server)
cargo clippy --all-targets -- -D warnings
PORT=17000 NTFY_URL=http://localhost:8080 NTFY_TOPIC=test cargo run

Send a sample alert:

curl -XPOST localhost:17000 -H 'content-type: application/json' -d '{
  "resolved": false, "level": "WARNING",
  "target": {"type": "Server", "id": "s1"},
  "data": {"type": "ServerCpu", "data": {"name": "srv", "percentage": 91.6}}
}'

Build the image locally:

docker build -t komodo-ntfy-rs .

⁠Releasing

Push a version tag:

git tag v1.2.3 && git push origin v1.2.3

release.yml⁠ runs the tests, builds linux/amd64 and linux/arm64 images on native runners, and pushes 1.2.3, 1.2 and latest to Docker Hub.

Required repository secrets: DOCKERHUB_USERNAME and DOCKERHUB_TOKEN (a Docker Hub access token with read/write scope).

Tag summary

Content type

Image

Digest

sha256:65d728cf7…

Size

6.5 MB

Last updated

8 days ago

docker pull pasinduakalpa/komodo-ntfy-rs