Analytics

Job success rates, average durations, failure breakdowns, and per-worker performance — scoped to your tenant for any date window up to 90 days.

Analytics summary

bash
GET /v1/ava/analytics?days=30
NameTypeRequiredDescription
daysintegerNoLookback window in days (1–90). Defaults to 30.
json
{
  "data": {
    "period_days": 30,
    "since": "2025-05-02T00:00:00Z",
    "jobs": {
      "total": 1840,
      "completed": 1791,
      "failed": 38,
      "cancelled": 11,
      "success_rate": 97.3,
      "avg_duration_ms": 1420,
      "by_trigger": {
        "scheduled": 1680,
        "manual": 120,
        "webhook": 40
      }
    },
    "by_worker": {
      "wkr_01hxyz": {
        "total": 960,
        "completed": 955,
        "failed": 5,
        "avg_duration_ms": null
      },
      "wkr_02hxyz": {
        "total": 880,
        "completed": 836,
        "failed": 33,
        "avg_duration_ms": null
      }
    }
  }
}

Identifying underperforming workers

typescript
const analytics = await fetch('/v1/ava/analytics?days=7').then(r => r.json())

const failing = Object.entries(analytics.data.by_worker)
  .map(([id, stats]) => ({
    worker_id: id,
    failure_rate: ((stats.failed / stats.total) * 100).toFixed(1),
  }))
  .filter(w => parseFloat(w.failure_rate) > 5)
  .sort((a, b) => parseFloat(b.failure_rate) - parseFloat(a.failure_rate))

console.log('Workers with >5% failure rate this week:', failing)
Tip:Pair analytics with the ava.job.failed webhook to get instant alerts on failures, and use the 7-day analytics window for weekly reliability reviews.