Skip to Content
ExamplesAPI Monitoring

API Monitoring

Monitor API and service health with flat numeric events. Keep events specific — one event per signal, not one event per endpoint.

EventValueWhy
api.requests.count1 per requestTrack total request volume
api.errors.count1 per errorCatch error rate increases
api.response.duration_msDuration in msMonitor response time and tail latency
rate_limit.hit.count1 per hitDetect when clients are being throttled

Logging events

await client.log({ agent: "api.v1", event: "api.requests.count", value: 1, meta: { method: "POST", path: "/v1/orders" } }); await client.log({ agent: "api.v1", event: "api.response.duration_ms", value: 145, meta: { method: "POST", path: "/v1/orders", status: 201 } }); await client.log({ agent: "api.v1", event: "api.errors.count", value: 1, meta: { method: "GET", path: "/v1/users", status: 500, error: "db_timeout" } });
EventPeriodAggregateConditionThresholdWhy
api.errors.counthoursumgt50Catch sustained error spikes
api.response.duration_mshourp95_estgt2000Tail latency affecting real users
api.response.duration_mshouraveragegt500General slowdown detection
rate_limit.hit.counthoursumgt100Clients being throttled too often

Using comparisons

Compare this hour’s error count to the same hour yesterday to distinguish a real incident from normal patterns:

const analytics = await client.getEventAnalytics(errorsEventID, { view: "window", period: "1h", previous: "previous_1d", }); // If value_pct_change is +200%, errors tripled vs the same hour yesterday — investigate // If value_pct_change is ~0%, this is baseline noise

Compare today’s request volume to the same day last week to spot traffic drops:

const analytics = await client.getEventAnalytics(requestsEventID, { view: "window", period: "1d", previous: "previous_7d", }); // A -50% drop in count_pct_change might mean a routing issue
Last updated on