Add support for repeat interval and emails to alertmanager type
This commit is contained in:
parent
468c416a39
commit
01e99e110f
5 changed files with 38 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
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"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
3h
|
3
type/__prometheus_alertmanager/parameter/optional
Normal file
3
type/__prometheus_alertmanager/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
|||
repeat-interval
|
||||
receiver-webhook
|
||||
receiver-email
|
|
@ -2,4 +2,3 @@ smtp-smarthost
|
|||
smtp-from
|
||||
smtp-user
|
||||
smtp-password
|
||||
receiver
|
||||
|
|
Reference in a new issue