1
0
Fork 0
Alertmanager to ntfy-sh webhook container for Kubernetes deployments
Find a file
2024-12-21 13:12:56 +01:00
.forgejo/workflows Update .forgejo/workflows/build.yaml.inactive 2024-09-08 15:37:58 +00:00
docker chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
grafana chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
sample-data chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
src chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
.gitignore initial commit 2022-11-02 14:46:55 +01:00
default.nix chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
Dockerfile chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
flake.lock chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
flake.nix chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
LICENSE chore: add latest changes and a build 2024-08-11 21:02:39 +02:00
module.nix Make the config name actually how it is in the readme 2024-02-04 23:51:05 +01:00
README.md chore: misc updates and refactor for alert aggregation 2024-12-21 13:12:56 +01:00
renovate.json Add renovate.json 2024-08-08 01:00:55 +00:00
Taskfile.yaml chore: add more building tools and scripts 2024-09-09 21:27:32 +02:00

🚨 alertmanager-ntfy 🚨

This project is a lightweight bridge between Prometheus Alertmanager and ntfy. It sends push notifications to your devices.

📦 Features

  • Configure via environment variables.
  • Exports Prometheus metrics to monitor webhook activity.
  • Built for Kubernetes, but works anywhere
  • Has a flake.nix

🚀 Getting Started

To send your Alertmanager alerts to ntfy, configure the following environment variables:

Variable Description Example
HTTP_ADDRESS Address to listen on localhost
HTTP_PORT Port to listen on 8080
NTFY_SERVER_URL ntfy server to send alerts to https://ntfy.sh
NTFY_USER Username for basic auth (optional) myuser
NTFY_PASS Password for basic auth (optional) supersecret
LOG_LEVEL Log level (debug, info, warn, error) info

Example

To expose the service on localhost:8080 and send alerts to an ntfy topic https://ntfy.sh/mytopic:

export HTTP_ADDRESS="localhost"
export HTTP_PORT="8080"
export NTFY_SERVER_URL="https://ntfy.sh/mytopic"
export NTFY_USER="myuser"
export NTFY_PASS="supersecret"
export LOG_LEVEL="info"

🛠️ Nix Support

For Nix/NixOS users, a flake.nix is provided for build, run and test.

Building with Nix

To build the container image: nix build .#container

If you are not on amd64 use nix build .#packages.x86_64-linux.container.

Push the built container to your preferred registry: nix run .#push-container

You can run the application directly from Nix with: nix run

To simulate alerts with test data: nix run '.#mock-hook'

🖥️ Nix Module

A Nix module is provided for easy setup and integration. A minimal configuration would look like this:

# Add to flake inputs
inputs.alertmanager-ntfy.url = "git+https://code.252.no/tommy/alertmanager-ntfy";

# Import the module in your configuration.nix
imports = [
  self.inputs.alertmanager-ntfy.nixosModules.default
];

# Enable the service and configure options
services.alertmanager-ntfy = {
  enable = true;
  httpAddress = "localhost";
  httpPort = "9999";
  ntfyTopic = "https://ntfy.sh/test";
  ntfyPriority = "high";
  envFile = "/var/src/secrets/alertmanager-ntfy/envfile";
};

🔍 Prometheus Metrics

The service exports Prometheus metrics for tracking webhook requests and errors. By default, these metrics are exposed at /metrics:

  • http_requests_total: Total number of HTTP requests received.
  • http_request_errors_total: Total number of errors encountered during request processing.

🤩 Gratitude

This project is based on the fantastic work by pinpox/alertmanager-ntfy, with adaptations for Kubernetes deployments and enhanced logging/metrics support.