Skip to Content
Timberlogs is in beta. Sign up at app.timberlogs.dev
API ReferenceStatistics

Statistics

Get aggregated metrics and usage statistics for your logs.

Get Statistics

GET /v1/stats

Retrieve aggregated log counts grouped by time or source.

Query Parameters

ParameterTypeDefaultDescription
fromstring7 days agoStart date (YYYY-MM-DD)
tostringTodayEnd date (YYYY-MM-DD)
groupBystringdayGrouping: hour, day, or source
sourcestring-Filter by source
environmentstring-Filter by environment
datasetstring-Filter by dataset

Response

Grouped by day (default):

{ "stats": [ { "date": "2024-01-02", "debug": 1500, "info": 8500, "warn": 350, "error": 150, "total": 10500 }, { "date": "2024-01-01", "debug": 1200, "info": 7800, "warn": 280, "error": 120, "total": 9400 } ], "totals": { "debug": 2700, "info": 16300, "warn": 630, "error": 270, "total": 19900 }, "period": { "from": "2024-01-01", "to": "2024-01-02", "groupBy": "day" } }

Grouped by hour:

{ "stats": [ { "date": "2024-01-02", "hour": 14, "debug": 100, "info": 450, "warn": 20, "error": 5, "total": 575 } ], "totals": { ... }, "period": { "groupBy": "hour" } }

Grouped by source:

{ "stats": [ { "source": "api-server", "debug": 1500, "info": 8000, "warn": 300, "error": 100, "total": 9900 }, { "source": "worker", "debug": 500, "info": 2000, "warn": 50, "error": 20, "total": 2570 } ], "totals": { ... }, "period": { "groupBy": "source" } }

Examples

Last 7 days by day:

curl -X GET "https://timberlogs-ingest.enaboapps.workers.dev/v1/stats" \ -H "Authorization: Bearer tb_live_xxxxxxxxxxxxx"

Last 24 hours by hour:

curl -X GET "https://timberlogs-ingest.enaboapps.workers.dev/v1/stats?from=2024-01-01&to=2024-01-02&groupBy=hour" \ -H "Authorization: Bearer tb_live_xxxxxxxxxxxxx"

By source:

curl -X GET "https://timberlogs-ingest.enaboapps.workers.dev/v1/stats?groupBy=source" \ -H "Authorization: Bearer tb_live_xxxxxxxxxxxxx"

Filter by environment:

curl -X GET "https://timberlogs-ingest.enaboapps.workers.dev/v1/stats?environment=production" \ -H "Authorization: Bearer tb_live_xxxxxxxxxxxxx"

Get Summary

GET /v1/stats/summary

Quick overview of today’s activity compared to yesterday.

Response

{ "today": { "debug": 500, "info": 3500, "warn": 150, "error": 50, "total": 4200 }, "comparison": { "yesterdayTotal": 3800, "changePercent": 11, "trend": "up" } }
FieldDescription
today.totalTotal logs today
today.debug/info/warn/errorCounts by level
comparison.yesterdayTotalYesterday’s total for comparison
comparison.changePercentPercentage change from yesterday
comparison.trendup, down, or stable

Example

curl -X GET "https://timberlogs-ingest.enaboapps.workers.dev/v1/stats/summary" \ -H "Authorization: Bearer tb_live_xxxxxxxxxxxxx"

Use Cases

Dashboard Metrics

Display key metrics in your application dashboard:

const response = await fetch( 'https://timberlogs-ingest.enaboapps.workers.dev/v1/stats/summary', { headers: { Authorization: `Bearer ${apiKey}` } } ) const { today, comparison } = await response.json() console.log(`Today: ${today.total} logs`) console.log(`Errors: ${today.error}`) console.log(`Trend: ${comparison.trend} (${comparison.changePercent}%)`)

Error Rate Monitoring

Track error rates over time:

const response = await fetch( 'https://timberlogs-ingest.enaboapps.workers.dev/v1/stats?groupBy=day', { headers: { Authorization: `Bearer ${apiKey}` } } ) const { stats } = await response.json() for (const day of stats) { const errorRate = ((day.error / day.total) * 100).toFixed(2) console.log(`${day.date}: ${errorRate}% errors`) }

Source Comparison

Compare log volume across services:

const response = await fetch( 'https://timberlogs-ingest.enaboapps.workers.dev/v1/stats?groupBy=source', { headers: { Authorization: `Bearer ${apiKey}` } } ) const { stats } = await response.json() for (const source of stats) { console.log(`${source.source}: ${source.total} logs`) }
Last updated on