Skip to content

Get statistics

GET
/triggers/{id}/stats
curl --request GET \
--url https://localhost:3000/api/v1/triggers/example/stats \
--header 'Authorization: <Authorization>'

Returns the aggregated event statistics. Requires trigger:read:{id} or trigger:read:*

id
required
string

Trigger ID (UUID)

from
string

Start (default: now-1h). Supports relative time: now-1h, now-24h

to
string

End (default: now). Supports relative time

interval
string

Bucket interval (default: 1m). E.g. 1m, 5m, 1h, 1d

filter
string

JSON filter on metadata

measure
string

Count (default) or sum:{metadata key}: sums that numeric key per bucket, read on raw events; events whose key is missing or not a JSON number are ignored

Event statistics

Media typeapplication/json
object
buckets
required
Array<object>
object
count
required

Count is the number of events (with measure=sum:, of those carrying a numeric key).

integer
time
required
string
value

Value is the sum of the key over the bucket, present with measure=sum: only.

number
from
required
string
measure

Measure is count, or sum: when the request asked for a sum.

string
to
required
string
total
required
integer
total_value

TotalValue is the sum over the window, present with measure=sum: only.

number
trigger_id
required
string format: uuid

Example

{
"buckets": [
{
"count": 152,
"time": "2024-01-15T10:00:00Z",
"value": 1.25
}
],
"from": "2024-01-15T09:30:00Z",
"measure": "sum:cost_usd",
"to": "2024-01-15T10:30:00Z",
"total": 1523,
"total_value": 12.5,
"trigger_id": "550e8400-e29b-41d4-a716-446655440000"
}

Invalid request, filter format or measure

Media typeapplication/json
object
error
required
string
message
string

Example

{
"error": "invalid_request",
"message": "Invalid request body"
}

Unauthorized

Media typeapplication/json
object
error
required
string
message
string

Example

{
"error": "invalid_request",
"message": "Invalid request body"
}

Permissions insuffisantes

Media typeapplication/json
object
error
required
string
message
string

Example

{
"error": "invalid_request",
"message": "Invalid request body"
}

Trigger not found

Media typeapplication/json
object
error
required
string
message
string

Example

{
"error": "invalid_request",
"message": "Invalid request body"
}

Erreur interne

Media typeapplication/json
object
error
required
string
message
string

Example

{
"error": "invalid_request",
"message": "Invalid request body"
}

Stats query timed out

Media typeapplication/json
object
error
required
string
message
string

Example

{
"error": "invalid_request",
"message": "Invalid request body"
}