#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat <<EOF | "${SCRIPT_DIR}/receive-alert"
{
"alert_name": "HighHttpErrorRate",
"alert_state": "firing",
"severity": "critical",
"service_name": "api-backend",
"deployment_environment": "development",
"service_version": "dev-latest",
"summary": "Elevated HTTP 5xx error rate on api-backend",
"description": "Service api-backend is experiencing a 5xx error rate of 12.50% (threshold: 5%).",
"observed_value": 12.50,
"threshold": 5.0,
"duration": "1m",
"dashboard_url": "http://localhost:3004/d/lifecycle-tracker-overview?var-environment=development&var-version=dev-latest",
"runbook_url": "on-call-engineer/runbook.md#highhttperrorrate",
"timestamp": "${TIMESTAMP}"
}
EOF
echo "==> Test incident successfully triggered and normalized!"