summaryrefslogtreecommitdiff
path: root/roles/monitoring/alerta
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-03-05 21:55:14 +0100
committerChristian Pointner <equinox@spreadspace.org>2022-03-05 21:55:14 +0100
commit9117d620ff6908ce92318db216403dab68c496ed (patch)
treeebd993e77e8230e8b300e5ff204d826dc1189cc9 /roles/monitoring/alerta
parentprometheus: cleanups and fixes in prep for alerta (diff)
initial commit for alerta role
Diffstat (limited to 'roles/monitoring/alerta')
-rw-r--r--roles/monitoring/alerta/defaults/main.yml2
-rw-r--r--roles/monitoring/alerta/tasks/main.yml32
-rw-r--r--roles/monitoring/alerta/templates/pod-spec.yml.j248
3 files changed, 82 insertions, 0 deletions
diff --git a/roles/monitoring/alerta/defaults/main.yml b/roles/monitoring/alerta/defaults/main.yml
new file mode 100644
index 00000000..034c8268
--- /dev/null
+++ b/roles/monitoring/alerta/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+# alerta_base_path: /srv/alerta
diff --git a/roles/monitoring/alerta/tasks/main.yml b/roles/monitoring/alerta/tasks/main.yml
new file mode 100644
index 00000000..af7530d8
--- /dev/null
+++ b/roles/monitoring/alerta/tasks/main.yml
@@ -0,0 +1,32 @@
+---
+- name: create alerta subdirectories
+ loop:
+ - config
+ - postgres
+ file:
+ path: "{{ alerta_base_path }}/{{ item }}"
+ state: directory
+
+- name: install alertad config template
+ copy:
+ content: |
+ DEBUG = {{ '{{' }} 'True' if env.DEBUG else 'False' {{ '}}' }}
+ SECRET = "{{ '{{' }} env.SECRET_KEY {{ '}}' }}"
+ PLUGINS = ['reject', 'blackout', 'heartbeat']
+ DEFAULT_ENVIRONMENT = 'unknown'
+ ALLOWED_ENVIRONMENTS = ['unknown', 'chaos-at-.*']
+ HEARTBEAT_EVENTS = ['PrometheusAlertmanagerE2eDeadManSwitch']
+ dest: "{{ alerta_base_path }}/config/alertad.conf.j2"
+
+- name: install pod manifest
+ vars:
+ kubernetes_standalone_pod:
+ name: "alerta"
+ spec: "{{ lookup('template', 'pod-spec.yml.j2') }}"
+ mode: "0600"
+ config_hash_items:
+ - path: "{{ alerta_base_path }}/config/alertad.conf.j2"
+ properties:
+ - checksum
+ include_role:
+ name: kubernetes/standalone/pod
diff --git a/roles/monitoring/alerta/templates/pod-spec.yml.j2 b/roles/monitoring/alerta/templates/pod-spec.yml.j2
new file mode 100644
index 00000000..e31686e3
--- /dev/null
+++ b/roles/monitoring/alerta/templates/pod-spec.yml.j2
@@ -0,0 +1,48 @@
+containers:
+- name: alerta
+ image: "alerta/alerta-web:8.7.0"
+ resources:
+ limits:
+ memory: "1Gi"
+ env:
+ - name: "DATABASE_URL"
+ value: "postgres://alerta:secret@127.0.0.1:5432/alerta"
+ - name: "AUTH_REQUIRED"
+ value: "True"
+ - name: "ADMIN_USERS"
+ value: "admin"
+ volumeMounts:
+ - name: config
+ mountPath: /app/alertad.conf.j2
+ subPath: alertad.conf.j2
+ readOnly: true
+ ports:
+ - containerPort: 8080
+ hostPort: 8080
+
+- name: postgresql
+ image: "postgres:14.2"
+ args:
+ - postgres
+ - -c
+ - listen_addresses=127.0.0.1
+ env:
+ - name: "POSTGRES_DB"
+ value: "alerta"
+ - name: "POSTGRES_USER"
+ value: "alerta"
+ - name: "POSTGRES_PASSWORD"
+ value: "secret"
+ volumeMounts:
+ - name: postgres
+ mountPath: /var/lib/postgresql/data
+
+volumes:
+- name: config
+ hostPath:
+ path: "{{ alerta_base_path }}/config"
+ type: Directory
+- name: postgres
+ hostPath:
+ path: "{{ alerta_base_path }}/postgres"
+ type: Directory