Returns aggregate statistics over alert_history for the caller's scope:
total, severity buckets, top-N alertname and system_key by count, plus MTTR
(mean time to resolve) and MTBF (mean time between failures, approximated).
Scope follows the same three modes as /alerts/totals:
organization_idomitted → caller's full hierarchy.organization_id=X→ single tenant.organization_id=X&include=descendants→ sub-tree drill-down.
MTBF formula:
- When both
from_dateandto_dateare provided:(to - from) / total. - Otherwise:
(max(starts_at) - min(starts_at)) / (total - 1). - Omitted from the response when the result is undefined.
GET
/alerts/stats
curl \
--request GET 'https://api.your-domain.com/api/alerts/stats' \
--header "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
{
"code": 200,
"message": "alert stats retrieved successfully",
"data": {
"total": 42,
"by_severity": {
"critical": 30,
"warning": 100,
"info": 26
},
"top_alertnames": [
{
"alertname": "string",
"count": 42
}
],
"top_systems": [
{
"system_key": "string",
"count": 42
}
],
"mttr_seconds": 42,
"mtbf_seconds": 42
}
}
Response examples (400)
{
"code": 400,
"message": "validation failed",
"data": {
"type": "validation_error",
"errors": [
{
"key": "username",
"message": "required",
"value": "string"
}
]
}
}
Response examples (401)
{
"code": 401,
"message": "invalid token",
"data": {}
}
Response examples (403)
{
"code": 403,
"message": "insufficient permissions",
"data": {}
}