Add minimal alertmanager type
This commit is contained in:
parent
25a6edfe75
commit
b25f66629c
4 changed files with 110 additions and 0 deletions
61
type/__prometheus_alertmanager/files/alertmanager.yml.sh
Executable file
61
type/__prometheus_alertmanager/files/alertmanager.yml.sh
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/bin/sh
|
||||
|
||||
cat << EOF
|
||||
global:
|
||||
# The smarthost and SMTP sender used for mail notifications.
|
||||
smtp_smarthost: '${SMTP_SMARTHOST:?}'
|
||||
smtp_from: '${SMTP_FROM:?}'
|
||||
smtp_auth_username: '${SMTP_USER:?}'
|
||||
smtp_auth_password: '${SMTP_PASSWORD}'
|
||||
|
||||
# The root route on which each incoming alert enters.
|
||||
route:
|
||||
# The labels by which incoming alerts are grouped together. For example,
|
||||
# multiple alerts coming in for cluster=A and alertname=LatencyHigh would
|
||||
# be batched into a single group.
|
||||
group_by: ['alertname', 'cluster', 'service']
|
||||
|
||||
# When a new group of alerts is created by an incoming alert, wait at
|
||||
# least 'group_wait' to send the initial notification.
|
||||
# This way ensures that you get multiple alerts for the same group that start
|
||||
# firing shortly after another are batched together on the first
|
||||
# notification.
|
||||
group_wait: 30s
|
||||
|
||||
# When the first notification was sent, wait 'group_interval' to send a batch
|
||||
# of new alerts that started firing for that group.
|
||||
group_interval: 5m
|
||||
|
||||
# If an alert has successfully been sent, wait 'repeat_interval' to
|
||||
# resend them.
|
||||
repeat_interval: 3h
|
||||
|
||||
# A default receiver
|
||||
receiver: admin-mails
|
||||
|
||||
# All the above attributes are inherited by all child routes and can
|
||||
# overwritten on each.
|
||||
|
||||
# The child route trees.
|
||||
routes: []
|
||||
|
||||
|
||||
# Inhibition rules allow to mute a set of alerts given that another alert is
|
||||
# firing.
|
||||
# We use this to mute any warning-level notifications if the same alert is
|
||||
# already critical.
|
||||
inhibit_rules:
|
||||
- source_match:
|
||||
severity: 'critical'
|
||||
target_match:
|
||||
severity: 'warning'
|
||||
# Apply inhibition if the alertname is the same.
|
||||
equal: ['alertname', 'cluster', 'service']
|
||||
|
||||
|
||||
receivers:
|
||||
- name: 'admin-mails'
|
||||
email_configs:
|
||||
- to: '${RECEIVER_EMAIL:?}'
|
||||
|
||||
EOF
|
44
type/__prometheus_alertmanager/manifest
Normal file
44
type/__prometheus_alertmanager/manifest
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
|
||||
os="$(cat "${__global:?}/explorer/os")"
|
||||
case "$os" in
|
||||
alpine)
|
||||
service=alertmanager
|
||||
package=alertmanager
|
||||
alertmanager_yml=/etc/alertmanager/alertmanager.yml
|
||||
;;
|
||||
|
||||
ubuntu|debian)
|
||||
service=prometheus-alertmanager
|
||||
package=prometheus-alertmanager
|
||||
alertmanager_yml=/etc/prometheus/alertmanager.yml
|
||||
;;
|
||||
*)
|
||||
echo "This type does not supper $os. Exiting." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
SMTP_SMARTHOST=$(cat "${__object:?}/parameter/smtp-smarthost")
|
||||
SMTP_FROM=$(cat "${__object:?}/parameter/smtp-from")
|
||||
SMTP_USER=$(cat "${__object:?}/parameter/smtp-user")
|
||||
SMTP_PASSWORD=$(cat "${__object:?}/parameter/smtp-password")
|
||||
export SMTP_SMARTHOST SMTP_USER SMTP_FROM SMTP_PASSWORD
|
||||
|
||||
RECEIVER_EMAIL=$(cat "${__object:?}/parameter/receiver")
|
||||
export RECEIVER_EMAIL
|
||||
|
||||
# Install Alertmanager.
|
||||
__package "$package"
|
||||
|
||||
# Generate and deploy configuration
|
||||
mkdir -p "${__object:?}/files"
|
||||
"${__type:?}/files/alertmanager.yml.sh" > "${__object:?}/files/alertmanager.yml"
|
||||
|
||||
require="__package/$package" __file "$alertmanager_yml" \
|
||||
--source "${__object:?}/files/alertmanager.yml" \
|
||||
--mode 0644 \
|
||||
--onchange "service $service restart"
|
||||
|
||||
require="__package/$package" __start_on_boot "$service"
|
||||
#require="__package/$package" __service "$service" --action start
|
5
type/__prometheus_alertmanager/parameter/required
Normal file
5
type/__prometheus_alertmanager/parameter/required
Normal file
|
@ -0,0 +1,5 @@
|
|||
smtp-smarthost
|
||||
smtp-from
|
||||
smtp-user
|
||||
smtp-password
|
||||
receiver
|
0
type/__prometheus_alertmanager/singleton
Normal file
0
type/__prometheus_alertmanager/singleton
Normal file
Reference in a new issue