From 45acb9f5c7b69ab82a33ebe3440bd2e613ac612d Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Fri, 10 Apr 2020 12:34:20 +0200 Subject: [PATCH] Load in the email template --- ansible/pre-deploy.yml | 3 +++ ansible/templates/alerta.conf | 1 + ansible/templates/email.tmpl | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 ansible/templates/email.tmpl diff --git a/ansible/pre-deploy.yml b/ansible/pre-deploy.yml index dfdb952..2753dc6 100644 --- a/ansible/pre-deploy.yml +++ b/ansible/pre-deploy.yml @@ -52,6 +52,8 @@ with_items: - src: config.json dest: /var/lib/alerta/config.json + - src: email.tmpl + dest: /var/lib/alerta/email.tmpl - name: Copy over the /app/ configurations become: true @@ -71,6 +73,7 @@ dokku_storage: app: alerta mounts: + - /var/lib/alerta/email.tmpl:/app/email.tmpl - /var/lib/alerta/alerta.conf:/app/alerta.conf - /var/lib/alerta/alertad.conf:/app/alertad.conf - /var/lib/alerta/config.json:/web/config.json diff --git a/ansible/templates/alerta.conf b/ansible/templates/alerta.conf index 540a967..5bd594e 100644 --- a/ansible/templates/alerta.conf +++ b/ansible/templates/alerta.conf @@ -16,6 +16,7 @@ email_type = text endpoint = http://localhost:8080/api key = {{ alerta_mailer_api_key }} mail_from = {{ mail_from }} +mail_template = /app/email.tmpl mail_to = {{ mail_to }} skip_mta = False smtp_host = {{ smtp_host }} diff --git a/ansible/templates/email.tmpl b/ansible/templates/email.tmpl new file mode 100644 index 0000000..98cdf78 --- /dev/null +++ b/ansible/templates/email.tmpl @@ -0,0 +1,34 @@ + +------------------------------------------------------------ +[{{ alert.status|title }}] {{ alert.environment }}: {{ alert.severity|title }} {{ alert.event }} on {{ alert.service|join(', ') }} {{ alert.resource }} +------------------------------------------------------------ + +Alert ID: {{ alert.id }} +Create Time: {{ alert.create_time }} +Environment: {{ alert.environment }} +Services: {{ alert.service|join(', ') }} +Resource: {{ alert.resource }} +Event: {{ alert.event }} +Group: {{ alert.group }} +Value: {{ alert.value }} +Severity: {{ alert.previous_severity|title}} -> {{ alert.severity|title }} +Status: {{ alert.status|title }} +Text: {{ alert.text }} +Duplicate Count: {{ alert.duplicate_count }} +Origin: {{ alert.origin }} +Tags: {{ alert.tags|join(', ') }} +{% for key,value in alert.attributes.items() -%} +{{ key|title }}: {{ value }} +{% endfor -%} + +{% if alert.raw_data %} +Raw Data +{{ alert.raw_data }} +{% endif %} + +Comrades! To Arms! + +To acknowledge this alert visit this URL: +{{ dashboard_url }}/#/alert/{{ alert.id }} + +Generated by {{ program }} on {{ hostname }} at {{ now }}