diff --git a/core-deployments.yaml b/core-deployments.yaml index 1bb1b9f..fce77a3 100644 --- a/core-deployments.yaml +++ b/core-deployments.yaml @@ -130,6 +130,11 @@ spec: targetRevision: 20.2.0 helm: releaseName: prometheus + valueFiles: + - $values/prometheus/values.yaml + - repoURL: https://git.ar21.de/yolokube/core-deployments.git + targetRevision: HEAD + ref: values - repoURL: https://git.ar21.de/yolokube/core-deployments.git targetRevision: HEAD path: prometheus diff --git a/prometheus/alertmanager-config.yaml b/prometheus/alertmanager-config.yaml new file mode 100644 index 0000000..8332b63 --- /dev/null +++ b/prometheus/alertmanager-config.yaml @@ -0,0 +1,61 @@ +--- +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/instance: prometheus + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: alertmanager + app.kubernetes.io/version: v0.25.0 + helm.sh/chart: alertmanager-0.24.1 + name: prometheus-alertmanager + namespace: prometheus +apiVersion: v1 +data: + alertmanager.yml: | + global: + resolve_timeout: 5m + + templates: + - '/etc/alertmanager/telegram.tmpl' + + route: + group_by: ['alertname'] + group_wait: 30s + group_interval: 30s + repeat_interval: 3h + receiver: 'tg1' + routes: + - matchers: + - severity=warning + receiver: 'tg1' + + - matchers: + - severity=critical + receiver: 'tg1' + + receivers: + - name: tg1 + telegram_configs: + - bot_token_file: '/etc/alertmanager/telegram-token' + chat_id: -995270884 + api_url: "https://api.telegram.org" + send_resolved: true + parse_mode: "HTML" + message: '{{ template "telegram.aaron" .}}' + + inhibit_rules: + - source_matchers: + - severity = critical + target_matchers: + - severity = warning + equal: ['alertname', 'server', 'instance'] + telegram.tmpl: | + {{ define "telegram.aaron" }} + {{ range .Alerts }} + {{ if eq .Status "firing"}}🔥 {{ .Labels.alertname }} 🔥{{ else }}✅ {{ .Labels.alertname }} ✅{{ end }} + {{ .Annotations.summary }} + + {{ .Annotations.description }} + {{ end }} + {{ end }} + diff --git a/prometheus/values.yaml b/prometheus/values.yaml new file mode 100644 index 0000000..1d79270 --- /dev/null +++ b/prometheus/values.yaml @@ -0,0 +1,7 @@ +alertmanager: + extraSecretMounts: + - name: telegram-api + mountPath: /etc/alertmanager/telegram-token + subPath: "" + secretName: telegram-api + readOnly: true \ No newline at end of file