Skip to main content

Query Logs

Search and retrieve logs from Recall.

Search Logs

GET /api/v1/logs

Request

curl "https://recall.brainzlab.ai/api/v1/logs?query=level:error%20since:1h" \
  -H "Authorization: Bearer sk_live_xxx"

Query Parameters

ParameterTypeDescription
querystringRecall Query Language query
limitintegerMax results (default: 50, max: 1000)
offsetintegerPagination offset
orderstringSort order: asc or desc (default: desc)

Response

{
  "data": [
    {
      "id": "log_abc123",
      "level": "error",
      "message": "Payment failed",
      "timestamp": "2024-01-15T10:30:00Z",
      "data": {
        "order_id": 123,
        "error": "Card declined"
      },
      "context": {
        "request_id": "req_xyz",
        "user": { "id": 456 }
      }
    }
  ],
  "meta": {
    "total": 150,
    "limit": 50,
    "offset": 0
  }
}

Get Single Log

GET /api/v1/logs/:id

Request

curl https://recall.brainzlab.ai/api/v1/logs/log_abc123 \
  -H "Authorization: Bearer sk_live_xxx"

Response

{
  "data": {
    "id": "log_abc123",
    "level": "error",
    "message": "Payment failed",
    "timestamp": "2024-01-15T10:30:00Z",
    "data": { ... },
    "context": { ... }
  }
}

Query Language

Use the Recall Query Language:
# Errors in last hour
query=level:error since:1h

# Specific user
query=data.user.id:123 since:7d

# Full text search
query="payment failed" level:error

# Multiple conditions
query=level:error env:production data.amount:>100

Statistics

Get aggregated statistics:
GET /api/v1/logs/stats

Request

curl "https://recall.brainzlab.ai/api/v1/logs/stats?query=since:24h&group_by=level" \
  -H "Authorization: Bearer sk_live_xxx"

Response

{
  "data": {
    "total": 10000,
    "groups": {
      "debug": 5000,
      "info": 4000,
      "warn": 500,
      "error": 450,
      "fatal": 50
    }
  }
}

Pagination

For large result sets:
# First page
GET /api/v1/logs?query=since:24h&limit=100&offset=0

# Second page
GET /api/v1/logs?query=since:24h&limit=100&offset=100

Export

Export logs as CSV or JSON:
POST /api/v1/logs/export

Request

curl https://recall.brainzlab.ai/api/v1/logs/export \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "level:error since:24h",
    "format": "csv",
    "email": "[email protected]"
  }'
Export is async. Results are emailed when ready.