2022-10-13 13:41:35 +02:00
|
|
|
# [ntfy-alertmanager]
|
|
|
|
|
2022-10-19 13:34:35 +02:00
|
|
|
[![builds.sr.ht status](https://builds.xenrox.net/~xenrox/ntfy-alertmanager/commits/master.svg)](https://builds.xenrox.net/~xenrox/ntfy-alertmanager/commits/master?)
|
|
|
|
|
2022-10-13 13:41:35 +02:00
|
|
|
A bridge between ntfy and Alertmanager.
|
|
|
|
|
2022-10-20 14:18:22 +02:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
Simply use go build or the [docker image] with [docker-compose file].
|
2023-01-14 21:26:57 +01:00
|
|
|
`ntfy-alertmanager:latest` is built from the latest tagged release while
|
|
|
|
`ntfy-alertmanager:dev` is built from the master branch.
|
2022-10-20 14:18:22 +02:00
|
|
|
|
2022-10-13 13:41:35 +02:00
|
|
|
## 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].
|
|
|
|
|
2023-03-09 17:02:05 +01:00
|
|
|
ntfy-alertmanager has support for setting ntfy [priority], [tags], [icon], [action buttons]
|
2023-07-07 21:37:11 +02:00
|
|
|
(which can be used to create an Alertmanager silence), [email notifications] and [phone calls].
|
2023-03-09 17:02:05 +01:00
|
|
|
Define a decreasing order of labels in the config file and map those labels to tags, priority, an icon or an email address.
|
2022-10-13 13:41:35 +02:00
|
|
|
|
2023-02-20 13:08:59 +01:00
|
|
|
- For priority and icon the first found value will be chosen. An icon for "resolved" alerts will take precedence.
|
2022-10-13 13:41:35 +02:00
|
|
|
- Tags are added together.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```
|
2023-02-10 17:16:13 +01:00
|
|
|
# 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
|
2022-10-13 13:41:35 +02:00
|
|
|
# http listen address
|
2022-10-20 14:18:22 +02:00
|
|
|
http-address :8080
|
2022-10-13 13:41:35 +02:00
|
|
|
# Log level (either debug, info, warning, error)
|
|
|
|
log-level info
|
2023-01-20 15:03:46 +01:00
|
|
|
# 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
|
2022-10-13 13:41:35 +02:00
|
|
|
# Optionally protect with HTTP basic authentication
|
|
|
|
user webhookUser
|
|
|
|
password webhookPass
|
|
|
|
|
|
|
|
labels {
|
|
|
|
order "severity,instance"
|
|
|
|
|
|
|
|
severity "critical" {
|
|
|
|
priority 5
|
|
|
|
tags "rotating_light"
|
2023-02-20 13:08:59 +01:00
|
|
|
icon "https://foo.com/critical.png"
|
2023-03-09 17:02:05 +01:00
|
|
|
# Forward messages which severity "critical" to the specified email address.
|
|
|
|
email-address foo@bar.com
|
2023-07-07 21:37:11 +02:00
|
|
|
# Call the specified number. Use `yes` to pick the first of your verified numbers.
|
|
|
|
call yes
|
2022-10-13 13:41:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
severity "info" {
|
|
|
|
priority 1
|
|
|
|
}
|
|
|
|
|
|
|
|
instance "example.com" {
|
|
|
|
tags "computer,example"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 13:08:59 +01:00
|
|
|
# Settings for resolved alerts
|
2023-02-12 17:08:58 +01:00
|
|
|
resolved {
|
|
|
|
tags "resolved,partying_face"
|
2023-02-20 13:08:59 +01:00
|
|
|
icon "https://foo.com/resolved.png"
|
2023-02-12 17:08:58 +01:00
|
|
|
}
|
|
|
|
|
2022-10-13 13:41:35 +02:00
|
|
|
ntfy {
|
|
|
|
# URL of the ntfy topic - required
|
|
|
|
topic https://ntfy.sh/alertmanager-alerts
|
2023-02-21 11:50:50 +01:00
|
|
|
# ntfy authentication via Basic Auth (https://docs.ntfy.sh/publish/#username-password)
|
2022-10-13 13:41:35 +02:00
|
|
|
user user
|
|
|
|
password pass
|
2023-02-21 11:50:50 +01:00
|
|
|
# ntfy authentication via access tokens (https://docs.ntfy.sh/publish/#access-tokens)
|
|
|
|
# Either access-token or a user/password combination can be used - not both.
|
|
|
|
access-token foobar
|
2023-03-09 17:02:05 +01:00
|
|
|
# Forward all messages to the specified email address.
|
|
|
|
email-address foo@bar.com
|
2023-07-07 21:37:11 +02:00
|
|
|
# Call the specified number for all alerts. Use `yes` to pick the first of your verified numbers.
|
|
|
|
call +123456789
|
2022-10-13 13:41:35 +02:00
|
|
|
}
|
2023-02-08 14:46:14 +01:00
|
|
|
|
2023-02-10 17:16:13 +01:00
|
|
|
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.
|
2023-02-12 14:28:24 +01:00
|
|
|
#
|
|
|
|
# When alert-mode is set to "single" all alert labels will be used to create the silence.
|
|
|
|
# When it is "multi" common labels between all the alerts will be used. WARNING: This
|
|
|
|
# could silence unwanted alerts.
|
2023-02-10 17:16:13 +01:00
|
|
|
silence-duration 24h
|
2023-02-12 14:15:02 +01:00
|
|
|
# Basic authentication (https://prometheus.io/docs/alerting/latest/https/)
|
|
|
|
user user
|
|
|
|
password pass
|
2023-02-12 14:58:37 +01:00
|
|
|
# By default the Alertmanager URL gets parsed from the webhook. In case that
|
|
|
|
# Alertmanger is not reachable under that URL, it can be overwritten here.
|
|
|
|
url https://alertmanager.xenrox.net
|
2023-02-10 17:16:13 +01:00
|
|
|
}
|
|
|
|
|
2023-02-08 14:46:14 +01:00
|
|
|
# When the alert-mode is set to single, ntfy-alertmanager will cache each single alert
|
|
|
|
# to avoid sending recurrences.
|
|
|
|
cache {
|
2023-03-08 22:05:15 +01:00
|
|
|
# The type of cache that will be used (either memory or redis; default is memory).
|
2023-03-08 16:30:58 +01:00
|
|
|
type memory
|
2023-02-08 14:46:14 +01:00
|
|
|
# How long messages stay in the cache for
|
|
|
|
duration 24h
|
2023-03-08 22:05:15 +01:00
|
|
|
|
|
|
|
# Memory cache settings
|
2023-02-08 14:46:14 +01:00
|
|
|
# Interval in which the cache is cleaned up
|
|
|
|
cleanup-interval 1h
|
2023-03-08 22:05:15 +01:00
|
|
|
|
|
|
|
# Redis cache settings
|
2023-03-08 22:17:32 +01:00
|
|
|
# URL to connect to redis (default: redis://localhost:6379)
|
|
|
|
redis-url redis://user:password@localhost:6789/3
|
2023-02-08 14:46:14 +01:00
|
|
|
}
|
2022-10-13 13:41:35 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Alertmanager config
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
receivers:
|
|
|
|
- name: "ntfy"
|
|
|
|
webhook_configs:
|
|
|
|
- url: "http://127.0.0.1:8080"
|
|
|
|
http_config:
|
|
|
|
basic_auth:
|
|
|
|
username: "webhookUser"
|
|
|
|
password: "webhookPass"
|
|
|
|
```
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
2023-03-09 13:27:52 +01:00
|
|
|
Report bugs on the [issue tracker], send patches/ask questions on the [mailing list]
|
|
|
|
or write to me directly on matrix [@xenrox:xenrox.net].
|
2022-10-13 13:41:35 +02:00
|
|
|
|
|
|
|
[ntfy-alertmanager]: https://hub.xenrox.net/~xenrox/ntfy-alertmanager/
|
|
|
|
[scfg]: https://git.sr.ht/~emersion/scfg
|
|
|
|
[priority]: https://ntfy.sh/docs/publish/#message-priority
|
|
|
|
[tags]: https://ntfy.sh/docs/publish/#tags-emojis
|
2023-02-20 13:08:59 +01:00
|
|
|
[icon]: https://docs.ntfy.sh/publish/#icons
|
|
|
|
[action buttons]: https://docs.ntfy.sh/publish/#action-buttons
|
2023-03-09 17:02:05 +01:00
|
|
|
[email notifications]: https://docs.ntfy.sh/publish/#e-mail-notifications
|
2023-07-07 21:37:11 +02:00
|
|
|
[phone calls]: https://ntfy.xenrox.net/docs/publish/#phone-calls
|
2022-10-13 13:41:35 +02:00
|
|
|
[issue tracker]: https://todo.xenrox.net/~xenrox/ntfy-alertmanager
|
2023-03-09 13:27:52 +01:00
|
|
|
[mailing list]: https://lists.xenrox.net/~xenrox/public-inbox
|
|
|
|
[@xenrox:xenrox.net]: https://matrix.to/#/@xenrox:xenrox.net
|
2022-10-20 14:18:22 +02:00
|
|
|
[docker image]: https://hub.docker.com/r/xenrox/ntfy-alertmanager
|
|
|
|
[docker-compose file]: https://git.xenrox.net/~xenrox/ntfy-alertmanager/tree/master/item/docker/docker-compose.yml
|