Calculating Service Level from raw /api/v2/analytics/queues/interval data

Could someone explain the exact formula for Service Level when aggregating raw interval data from the queue observations endpoint? My Datadog integration pulls the handled and abandoned counts, but I cannot get the SLA percentage to match the dashboard when summing intervals with zero handled calls. Is it a weighted average or a simple sum of handled_within_sla over total handled?

It’s worth reviewing at summing handled_within_sla and handled separately across all intervals, then dividing the totals, because zero-handled intervals shouldn’t skew a weighted average.

const totalHandled = intervals.reduce((sum, i) => sum + i.handled, 0);
const totalWithinSla = intervals.reduce((sum, i) => sum + i.handled_within_sla, 0);
const serviceLevel = totalHandled > 0 ? (totalWithinSla / totalHandled) * 100 : 0;
1 Like