No description
Find a file
Thorben Günther c919ec9af2
Add ability to silence alerts with ntfy action
For now only for the single alert mode.
This is implemented as an action button, that will send an API request
to ntfy-alertmanager itself instead of Alertmanager. Here ntfy-alertmanager
acts as a proxy and will then do the API request for actually creating
the silence in Alertmanager.
This is founded in a limitation of ntfy, that seemingly does not allow a
json body with more than one key.
2023-02-12 03:04:17 +01:00
docker Add version flag 2023-01-16 14:35:53 +01:00
.build.yml Add version flag 2023-01-16 14:35:53 +01:00
.gitignore Add version flag 2023-01-16 14:35:53 +01:00
cache.go cache: Take alert status (firing, resolved) into account 2023-02-08 20:41:05 +01:00
config.go config: Add required settings for silencing alerts 2023-02-11 13:56:06 +01:00
config_test.go config: Add required settings for silencing alerts 2023-02-11 13:56:06 +01:00
functions.go Support ntfy tags 2022-10-12 17:04:44 +02:00
go.mod Upgrade dependencies 2022-10-13 01:15:04 +02:00
go.sum Upgrade dependencies 2022-10-13 01:15:04 +02:00
LICENSE Initial commit 2022-10-09 14:19:48 +02:00
main.go Add ability to silence alerts with ntfy action 2023-02-12 03:04:17 +01:00
README.md config: Add required settings for silencing alerts 2023-02-11 13:56:06 +01:00
silence.go Add ability to silence alerts with ntfy action 2023-02-12 03:04:17 +01:00

ntfy-alertmanager

builds.sr.ht status

A bridge between ntfy and Alertmanager.

Installation

Simply use go build or the docker image with docker-compose file. ntfy-alertmanager:latest is built from the latest tagged release while ntfy-alertmanager:dev is built from the master branch.

Configuration

You can specify the configuration file location with the --config flag. By default the configuration file will be read from /etc/ntfy-alertmanager/config. The format of this file is scfg.

ntfy-alertmanager has support for setting ntfy priority and tags. Define a decreasing order of labels in the config file and map those labels to tags or priority.

  • For priority the first found value will be chosen.
  • Tags are added together.

Example:

# Public facing base URL of the service (e.g. https://ntfy-alertmanager.xenrox.net)
# This setting is required for the "Silence" feature.
base-url https://ntfy-alertmanager.xenrox.net
# http listen address
http-address :8080
# Log level (either debug, info, warning, error)
log-level info
# When multiple alerts are grouped together by Alertmanager, they can either be sent
# each on their own (single mode) or be kept together (multi mode) (either single or multi; default is single)
alert-mode single
# Optionally protect with HTTP basic authentication
user webhookUser
password webhookPass

labels {
    order "severity,instance"

    severity "critical" {
        priority 5
        tags "rotating_light"
    }

    severity "info" {
        priority 1
    }

    instance "example.com" {
        tags "computer,example"
    }
}

ntfy {
    # URL of the ntfy topic - required
    topic https://ntfy.sh/alertmanager-alerts
    # ntfy access control (https://ntfy.sh/docs/config/#access-control)
    user user
    password pass
}

alertmanager {
    # If set, the ntfy message will contain a "Silence" button, which can be used
    # to create a silence via the Alertmanager API. Because of limitations in ntfy,
    # the request will be proxied through ntfy-alertmanager. Therefore ntfy-alertmanager
    # needs to be exposed to external network requests and base-url has to be set.
    silence-duration 24h
}

# When the alert-mode is set to single, ntfy-alertmanager will cache each single alert
# to avoid sending recurrences.
cache {
    # How long messages stay in the cache for
    duration 24h
    # Interval in which the cache is cleaned up
    cleanup-interval 1h
}

Alertmanager config

receivers:
    - name: "ntfy"
      webhook_configs:
          - url: "http://127.0.0.1:8080"
            http_config:
                basic_auth:
                    username: "webhookUser"
                    password: "webhookPass"

Contributing

Report bugs on the issue tracker.