From 2bf9fb5096163fd8b7332cb0e9d07253e03ff39f Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 14 Oct 2024 22:15:05 +0200 Subject: [PATCH] feat : Alert Manager start --- cloud/config/alertmanager/alertmanager.yml | 18 ++++++++++-------- cloud/config/grafana/.env.example | 6 +++++- cloud/config/read/prometheus.yml | 13 +++++++------ docker-compose.yaml | 2 ++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/cloud/config/alertmanager/alertmanager.yml b/cloud/config/alertmanager/alertmanager.yml index 0d688c7..3c5e575 100644 --- a/cloud/config/alertmanager/alertmanager.yml +++ b/cloud/config/alertmanager/alertmanager.yml @@ -3,16 +3,18 @@ global: route: group_by: ['alertname'] - group_wait: 30s - group_interval: 5m - repeat_interval: 3h + group_wait: 10s + group_interval: 1m + repeat_interval: 3s receiver: 'email_notifications' receivers: - name: 'email_notifications' email_configs: - - to: 'email@example.com' - from: 'alert@example.com' - smarthost: 'smtp.example.com:587' - auth_username: 'username' - auth_password: 'password' \ No newline at end of file + - to: '{{ env "SMTP_USERNAME_TO" }}' + from: '{{ env "SMTP_USERNAME_FROM" }}' + smarthost: 'smtp.gmail.com:587' + auth_username: '{{ env "SMTP_USERNAME" }}' + auth_password: '{{ env "SMTP_PASSWORD" }}' + require_tls: true +service alertmanager restart \ No newline at end of file diff --git a/cloud/config/grafana/.env.example b/cloud/config/grafana/.env.example index 0c08869..9fee2ee 100644 --- a/cloud/config/grafana/.env.example +++ b/cloud/config/grafana/.env.example @@ -1,2 +1,6 @@ CLIENT_ID=TODO -CLIENT_SECRET=TODO \ No newline at end of file +CLIENT_SECRET=TODO +SMTP_USERNAME=TODO +SMTP_PASSWORD=TODO +SMTP_USERNAME_TO=TODO +SMTP_USERNAME_FROM=TODO \ No newline at end of file diff --git a/cloud/config/read/prometheus.yml b/cloud/config/read/prometheus.yml index 9a37375..a15b150 100644 --- a/cloud/config/read/prometheus.yml +++ b/cloud/config/read/prometheus.yml @@ -4,15 +4,16 @@ global: evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). -# Alertmanager configuration -#alerting: -# alertmanagers: -# - static_configs: -# - targets: - # - alertmanager:9093 +#Alertmanager configuration +alerting: + alertmanagers: + - static_configs: + - targets: + - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: +- "health_alert.yml" # - "first_rules.yml" # - "second_rules.yml" diff --git a/docker-compose.yaml b/docker-compose.yaml index 18711de..bda8231 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -24,6 +24,8 @@ services: - ./cloud/config/alertmanager:/etc/alertmanager command: - --config.file=/etc/alertmanager/alertmanager.yml + env_file: + - ./cloud/config/.env grafana: image: grafana/grafana ports: