Files
MessageGateway/app/models/alertmanager.py
Sergey Antropov b90def35ed Initial commit: Message Gateway project
- FastAPI приложение для отправки мониторинговых алертов в мессенджеры
- Поддержка Telegram и MAX/VK
- Интеграция с Grafana, Zabbix, AlertManager
- Автоматическое создание тикетов в Jira
- Управление группами мессенджеров через API
- Декораторы для авторизации и скрытия эндпоинтов
- Подробная документация в папке docs/

Автор: Сергей Антропов
Сайт: https://devops.org.ru
2025-11-12 20:25:11 +03:00

70 lines
3.1 KiB
Python

"""
Модели данных для AlertManager webhooks.
Автор: Сергей Антропов
Сайт: https://devops.org.ru
"""
from typing import Dict, Any, Optional
from pydantic import BaseModel, Field
class PrometheusAlert(BaseModel):
"""Модель данных вебхука из AlertManager."""
status: str = Field(..., description="Статус алерта (firing, resolved)", examples=["firing"])
externalURL: str = Field(..., description="Внешний URL AlertManager", examples=["http://alertmanager.example.com"])
commonLabels: Dict[str, str] = Field(..., description="Общие метки алерта")
commonAnnotations: Dict[str, str] = Field(..., description="Общие аннотации алерта")
model_config = {
"json_schema_extra": {
"examples": [
{
"status": "firing",
"externalURL": "http://alertmanager.example.com",
"commonLabels": {
"alertname": "HighCPUUsage",
"severity": "critical",
"namespace": "production",
"pod": "app-deployment-7d8f9b4c5-abc123",
"container": "app-container"
},
"commonAnnotations": {
"summary": "High CPU usage detected in production namespace",
"description": "CPU usage is above 90% for 5 minutes on pod app-deployment-7d8f9b4c5-abc123",
"runbook_url": "https://wiki.example.com/runbooks/high-cpu-usage"
}
},
{
"status": "resolved",
"externalURL": "http://alertmanager.example.com",
"commonLabels": {
"alertname": "HighCPUUsage",
"severity": "critical",
"namespace": "production",
"pod": "app-deployment-7d8f9b4c5-abc123",
"container": "app-container"
},
"commonAnnotations": {
"summary": "High CPU usage resolved in production namespace",
"description": "CPU usage has returned to normal levels on pod app-deployment-7d8f9b4c5-abc123"
}
},
{
"status": "firing",
"externalURL": "http://alertmanager.example.com",
"commonLabels": {
"alertname": "PodCrashLooping",
"severity": "warning",
"namespace": "staging",
"pod": "test-app-5f6g7h8i9-jkl456"
},
"commonAnnotations": {
"summary": "Pod is crash looping",
"description": "Pod test-app-5f6g7h8i9-jkl456 has restarted 5 times in the last 10 minutes"
}
}
]
}
}