readme: Move example config out

This commit is contained in:
Thorben Günther 2023-07-19 15:17:36 +02:00
parent 913a076c52
commit a908ce78ab
No known key found for this signature in database
GPG key ID: 415CD778D8C5AFED
2 changed files with 95 additions and 97 deletions

101
README.md
View file

@ -14,7 +14,8 @@ Simply use go build or the [docker image] with [docker-compose file].
You can specify the configuration file location with the `--config` flag. By default 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 the configuration file will be read from `/etc/ntfy-alertmanager/config`. The format
of this file is [scfg]. of this file is [scfg] and there is an [example configuration file] in this repo.
Furthermore you can take a look at [my deployment].
ntfy-alertmanager has support for setting ntfy [priority], [tags], [icon], [action buttons] ntfy-alertmanager has support for setting ntfy [priority], [tags], [icon], [action buttons]
(which can be used to create an Alertmanager silence), [email notifications] and [phone calls]. (which can be used to create an Alertmanager silence), [email notifications] and [phone calls].
@ -23,102 +24,6 @@ Define a decreasing order of labels in the config file and map those labels to t
- For priority and icon the first found value will be chosen. An icon for "resolved" alerts will take precedence. - For priority and icon the first found value will be chosen. An icon for "resolved" alerts will take precedence.
- Tags are added together. - 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 multi)
alert-mode single
# Optionally protect with HTTP basic authentication
user webhookUser
password webhookPass
labels {
order "severity,instance"
severity "critical" {
priority 5
tags "rotating_light"
icon "https://foo.com/critical.png"
# Forward messages which severity "critical" to the specified email address.
email-address foo@bar.com
# Call the specified number. Use `yes` to pick the first of your verified numbers.
call yes
}
severity "info" {
priority 1
}
instance "example.com" {
tags "computer,example"
}
}
# Settings for resolved alerts
resolved {
tags "resolved,partying_face"
icon "https://foo.com/resolved.png"
}
ntfy {
# URL of the ntfy topic - required
topic https://ntfy.sh/alertmanager-alerts
# ntfy authentication via Basic Auth (https://docs.ntfy.sh/publish/#username-password)
user user
password pass
# 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
# Forward all messages to the specified email address.
email-address foo@bar.com
# Call the specified number for all alerts. Use `yes` to pick the first of your verified numbers.
call +123456789
}
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.
#
# 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.
silence-duration 24h
# Basic authentication (https://prometheus.io/docs/alerting/latest/https/)
user user
password pass
# 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
}
# When the alert-mode is set to single, ntfy-alertmanager will cache each single alert
# to avoid sending recurrences.
cache {
# The type of cache that will be used (either disabled, memory or redis; default is disabled).
type memory
# How long messages stay in the cache for
duration 24h
# Memory cache settings
# Interval in which the cache is cleaned up
cleanup-interval 1h
# Redis cache settings
# URL to connect to redis (default: redis://localhost:6379)
redis-url redis://user:password@localhost:6789/3
}
```
### Alertmanager config ### Alertmanager config
```yaml ```yaml
@ -150,3 +55,5 @@ or write to me directly on matrix [@xenrox:xenrox.net].
[@xenrox:xenrox.net]: https://matrix.to/#/@xenrox:xenrox.net [@xenrox:xenrox.net]: https://matrix.to/#/@xenrox:xenrox.net
[docker image]: https://hub.docker.com/r/xenrox/ntfy-alertmanager [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 [docker-compose file]: https://git.xenrox.net/~xenrox/ntfy-alertmanager/tree/master/item/docker/docker-compose.yml
[example configuration file]: https://git.xenrox.net/~xenrox/ntfy-alertmanager/tree/master/item/config.scfg
[my deployment]: https://git.xenrox.net/~xenrox/ansible/tree/master/item/roles/alertmanager/templates/ntfy-alertmanager.j2

91
config.scfg Normal file
View file

@ -0,0 +1,91 @@
# 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 multi)
alert-mode single
# Optionally protect with HTTP basic authentication
user webhookUser
password webhookPass
labels {
order "severity,instance"
severity "critical" {
priority 5
tags "rotating_light"
icon "https://foo.com/critical.png"
# Forward messages which severity "critical" to the specified email address.
email-address foo@bar.com
# Call the specified number. Use `yes` to pick the first of your verified numbers.
call yes
}
severity "info" {
priority 1
}
instance "example.com" {
tags "computer,example"
}
}
# Settings for resolved alerts
resolved {
tags "resolved,partying_face"
icon "https://foo.com/resolved.png"
}
ntfy {
# URL of the ntfy topic - required
topic https://ntfy.sh/alertmanager-alerts
# ntfy authentication via Basic Auth (https://docs.ntfy.sh/publish/#username-password)
user user
password pass
# 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
# Forward all messages to the specified email address.
email-address foo@bar.com
# Call the specified number for all alerts. Use `yes` to pick the first of your verified numbers.
call +123456789
}
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.
#
# 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.
silence-duration 24h
# Basic authentication (https://prometheus.io/docs/alerting/latest/https/)
user user
password pass
# 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
}
# When the alert-mode is set to single, ntfy-alertmanager will cache each single alert
# to avoid sending recurrences.
cache {
# The type of cache that will be used (either disabled, memory or redis; default is disabled).
type memory
# How long messages stay in the cache for
duration 24h
# Memory cache settings
# Interval in which the cache is cleaned up
cleanup-interval 1h
# Redis cache settings
# URL to connect to redis (default: redis://localhost:6379)
redis-url redis://user:password@localhost:6789/3
}