groups:
  - name: application_health
    interval: 60s
    rules:
      - alert: ApplicationDown
        expr: app_health_up == 0
        for: 3m
        labels:
          severity: critical
        annotations:
          summary: "Application {{ $labels.app }} is down"
          description: "{{ $labels.app }} ({{ $labels.url }}) has been failing health checks for more than 3 minutes."

      - alert: ApplicationSlowResponse
        expr: app_health_response_time_seconds > 10
        for: 5m
        labels:
          severity: medium
        annotations:
          summary: "Application {{ $labels.app }} responding slowly ({{ $value }}s)"
          description: "{{ $labels.app }} response time exceeds 10 seconds."

      - alert: ApplicationContentMismatch
        expr: app_health_content_match == 0
        for: 5m
        labels:
          severity: high
        annotations:
          summary: "Application {{ $labels.app }} content check failed"
          description: "{{ $labels.app }} returned unexpected content. The application may be malfunctioning or returning error pages."

      - alert: ApplicationStatusCodeError
        expr: app_health_status_code >= 500
        for: 3m
        labels:
          severity: high
        annotations:
          summary: "Application {{ $labels.app }} returning HTTP {{ $value }}"
          description: "{{ $labels.app }} is returning server error status codes."
