# AlertManager configuration for VDS PDF Orchestrator

global:
  smtp_smarthost: 'localhost:587'
  smtp_from: 'alerts@vds-pdf-orchestrator.com'
  smtp_auth_username: 'alerts@vds-pdf-orchestrator.com'
  smtp_auth_password: 'your-smtp-password'

route:
  group_by: ['alertname', 'environment', 'service']
  group_wait: 10s
  group_interval: 10s
  repeat_interval: 1h
  receiver: 'web.hook'
  routes:
    - match:
        severity: critical
      receiver: 'critical-alerts'
    - match:
        severity: warning
      receiver: 'warning-alerts'
    - match:
        service: vds-pdf-orchestrator
      receiver: 'vds-alerts'

receivers:
  - name: 'web.hook'
    webhook_configs:
      - url: 'http://localhost:5001/'

  - name: 'critical-alerts'
    email_configs:
      - to: 'ops-team@vds-pdf-orchestrator.com'
        subject: '[CRITICAL] VDS PDF Orchestrator Alert'
        body: |
          {{ range .Alerts }}
          Alert: {{ .Annotations.summary }}
          Description: {{ .Annotations.description }}
          Labels: {{ range .Labels.SortedPairs }}{{ .Name }}={{ .Value }}{{ end }}
          {{ end }}
    slack_configs:
      - api_url: 'YOUR_SLACK_WEBHOOK_URL'
        channel: '#alerts-critical'
        title: 'Critical Alert: {{ .GroupLabels.alertname }}'
        text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'

  - name: 'warning-alerts'
    email_configs:
      - to: 'dev-team@vds-pdf-orchestrator.com'
        subject: '[WARNING] VDS PDF Orchestrator Alert'
        body: |
          {{ range .Alerts }}
          Alert: {{ .Annotations.summary }}
          Description: {{ .Annotations.description }}
          Labels: {{ range .Labels.SortedPairs }}{{ .Name }}={{ .Value }}{{ end }}
          {{ end }}

  - name: 'vds-alerts'
    webhook_configs:
      - url: 'http://vds-pdf-orchestrator:8000/webhooks/alerts'
        send_resolved: true
    slack_configs:
      - api_url: 'YOUR_SLACK_WEBHOOK_URL'
        channel: '#vds-pdf'
        title: 'VDS PDF Alert: {{ .GroupLabels.alertname }}'
        text: |
          {{ range .Alerts }}
          *Alert:* {{ .Annotations.summary }}
          *Description:* {{ .Annotations.description }}
          *Severity:* {{ .Labels.severity }}
          {{ end }}

inhibit_rules:
  # Don't send warnings if there are critical alerts for the same service
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['service', 'alertname']

# Define custom templates
templates:
  - '/etc/alertmanager/templates/*.tmpl'