Add Metrics API Endpoints to Event Manager
Create aggregation endpoints in Event Manager API to support integration metrics queries.
- Integration metrics:
GET /api/integrations/{source_id}/metrics?org_id={org_id}&days={days} - Organization metrics:
GET /api/organizations/{org_id}/metrics?days={days} - Time-series:
GET /api/organizations/{org_id}/metrics/timeseries?days={days}&bucket={bucket} - Add database indexes on: (organization_id, timestamp), (source_id, result, timestamp)
- Use SQL aggregation functions (COUNT, GROUP BY) for performance
- Cache responses for 5-15 minutes; limit time range to max 90 days
Example:
Integration metrics response:
{
"sourceId": "adp-sync",
"totalEvents": 1250,
"successCount": 1228,
"failureCount": 22,
"successRate": 98.24,
"lastEventTimestamp": "2025-11-06T15:30:00Z"
}
Organization metrics response:
{
"integrations": [
{
"sourceId": "adp-sync",
"totalEvents": 1250,
"successRate": 98.24
},
{
"sourceId": "qb-import",
"totalEvents": 45,
"successRate": 88.89
}
],
"aggregateTotals": {
"totalEvents": 1295,
"successCount": 1268,
"failureCount": 27,
"successRate": 97.91
}
}
Time-series response:
{
"buckets": [
{
"timestamp": "2025-11-01T00:00:00Z",
"totalEvents": 125,
"successCount": 122,
"failureCount": 3,
"integrations": {
"adp-sync": 100,
"qb-import": 25
}
}
]
}