6
0
Fork 0

Add support for repeat interval and emails to alertmanager type

This commit is contained in:
Timothée Floure 2021-03-29 19:21:55 +02:00
parent 468c416a39
commit 01e99e110f
Signed by: tfloure
GPG Key ID: 4502C902C00A1E12
5 changed files with 38 additions and 9 deletions

View File

@ -28,10 +28,10 @@ route:
# If an alert has successfully been sent, wait 'repeat_interval' to
# resend them.
repeat_interval: 3h
repeat_interval: ${REPEAT_INTERVAL:?}
# A default receiver
receiver: admin-mails
receiver: admins
# All the above attributes are inherited by all child routes and can
# overwritten on each.
@ -54,8 +54,20 @@ inhibit_rules:
receivers:
- name: 'admin-mails'
email_configs:
- to: '${RECEIVER_EMAIL:?}'
- name: 'admins'
EOF
if [ -n "$RECEIVER_EMAIL" ]; then
cat << EOF
email_configs:
- to: '$RECEIVER_EMAIL'
send_resolved: true
EOF
fi
if [ -n "$RECEIVER_WEBHOOK" ]; then
cat << EOF
webhook_configs:
- url: ${RECEIVER_WEBHOOK:?}
EOF
fi

View File

@ -25,8 +25,22 @@ 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
if [ -f "${__object:?}/parameter/receiver-email" ]; then
RECEIVER_EMAIL=$(cat "${__object:?}/parameter/receiver-email")
export RECEIVER_EMAIL
fi
if [ -f "${__object:?}/parameter/receiver-webhook" ]; then
RECEIVER_WEBHOOK=$(cat "${__object:?}/parameter/receiver-webhook")
export RECEIVER_WEBHOOK
fi
if [ -z "$RECEIVER_EMAIL" ] && [ -z "$RECEIVER_WEBHOOK" ]; then
echo "At least one receiver must be configured." >&2
exit 1
fi
REPEAT_INTERVAL=$(cat "${__object:?}/parameter/repeat-interval")
export REPEAT_INTERVAL
# Install Alertmanager.
__package "$package"

View File

@ -0,0 +1 @@
3h

View File

@ -0,0 +1,3 @@
repeat-interval
receiver-webhook
receiver-email

View File

@ -2,4 +2,3 @@ smtp-smarthost
smtp-from
smtp-user
smtp-password
receiver