From c3903238dca6413da6f7af25513a51c8c54af88d Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Sat, 25 Apr 2026 05:34:01 +0300 Subject: [PATCH] feat: Add Alertmanager configuration with severity-based routing and multi-channel notifications - Add global configuration with 5m resolve timeout and Slack webhook URL placeholder - Add template directory reference for custom alert notification templates - Add route configuration with grouping by alertname, severity, and service (10s wait/interval, 12h repeat) - Add severity-based routing (critical, warning, info) with dedicated receivers - Add default Slack receiver for #telecom-platform-alerts channel --- monitoring/alertmanager/alertmanager.yml | 124 +++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 monitoring/alertmanager/alertmanager.yml diff --git a/monitoring/alertmanager/alertmanager.yml b/monitoring/alertmanager/alertmanager.yml new file mode 100644 index 0000000..54c2b1c --- /dev/null +++ b/monitoring/alertmanager/alertmanager.yml @@ -0,0 +1,124 @@ +global: + resolve_timeout: 5m + # Slack webhook URL (replace with actual webhook) + slack_api_url: 'https://hooks.slack.com/services/YOUR/WEBHOOK/URL' + +# Templates for alert notifications +templates: + - '/etc/alertmanager/templates/*.tmpl' + +# Route configuration +route: + group_by: ['alertname', 'severity', 'service'] + group_wait: 10s + group_interval: 10s + repeat_interval: 12h + receiver: 'default' + + routes: + # Critical alerts go to critical receiver + - match: + severity: critical + receiver: 'critical' + continue: false + + # Warning alerts go to warning receiver + - match: + severity: warning + receiver: 'warning' + continue: false + + # Info alerts go to info receiver + - match: + severity: info + receiver: 'info' + continue: false + +# Receivers configuration +receivers: + - name: 'default' + slack_configs: + - channel: '#telecom-platform-alerts' + send_resolved: true + title: '{{ .GroupLabels.alertname }}' + text: >- + {{ range .Alerts }} + Alert: {{ .Labels.alertname }} + Severity: {{ .Labels.severity }} + Service: {{ .Labels.service }} + Description: {{ .Annotations.description }} + {{ end }} + + - name: 'critical' + slack_configs: + - channel: '#telecom-platform-critical' + send_resolved: true + title: '🚨 CRITICAL: {{ .GroupLabels.alertname }}' + color: 'danger' + text: >- + {{ range .Alerts }} + Alert: {{ .Labels.alertname }} + Severity: {{ .Labels.severity }} + Service: {{ .Labels.service }} + Description: {{ .Annotations.description }} + {{ end }} + # Email configuration for critical alerts + email_configs: + - to: 'oncall@telecom-platform.com' + from: 'alertmanager@telecom-platform.com' + headers: + Subject: '🚨 CRITICAL: {{ .GroupLabels.alertname }}' + html: >- + {{ range .Alerts }} +

{{ .Labels.alertname }}

+

Severity: {{ .Labels.severity }}

+

Service: {{ .Labels.service }}

+

Description: {{ .Annotations.description }}

+
+ {{ end }} + + - name: 'warning' + slack_configs: + - channel: '#telecom-platform-warnings' + send_resolved: true + title: 'âš ī¸ WARNING: {{ .GroupLabels.alertname }}' + color: 'warning' + text: >- + {{ range .Alerts }} + Alert: {{ .Labels.alertname }} + Severity: {{ .Labels.severity }} + Service: {{ .Labels.service }} + Description: {{ .Annotations.description }} + {{ end }} + + - name: 'info' + slack_configs: + - channel: '#telecom-platform-info' + send_resolved: true + title: 'â„šī¸ INFO: {{ .GroupLabels.alertname }}' + color: 'good' + text: >- + {{ range .Alerts }} + Alert: {{ .Labels.alertname }} + Severity: {{ .Labels.severity }} + Service: {{ .Labels.service }} + Description: {{ .Annotations.description }} + {{ end }} + +# Inhibition rules +inhibit_rules: + # If a critical alert is firing, inhibit warnings for the same service + - source_match: + severity: 'critical' + target_match: + severity: 'warning' + equal: ['service'] + target_match_re: + alertname: '.*' + + # If a service is down, inhibit other alerts for that service + - source_match: + alertname: '.*Down' + target_match_re: + alertname: '.*' + equal: ['service']