Monitoring & Observability

Monitor PULSE health and performance

Monitoring & Observability

Monitor PULSE health, performance, and reliability in production.

Health Checks

Basic Health Check

curl https://api.example.com/health

Response:

{
  "status": "ok",
  "timestamp": 1703001234567
}

Readiness Check

curl https://api.example.com/health/ready

Checks all dependencies:

{
  "status": "ready",
  "dependencies": {
    "database": "ok",
    "cache": "ok",
    "api_secret_configured": true
  }
}

Cloudflare Analytics

PULSE automatically reports to Cloudflare Analytics:

  1. Go to Cloudflare Dashboard
  2. Select Workers → Your Worker
  3. View Analytics:
    • Requests — Total API calls
    • Latency — p50, p95, p99 response times
    • Errors — 4xx and 5xx error rates
    • CPU — CPU usage per request

Datadog Integration

Enable Datadog monitoring:

# Set API key
wrangler secret put DATADOG_API_KEY --env production

# Restart worker
wrangler deploy --env production

Key Metrics to Monitor

Performance

MetricTargetAlert
API latency (p95)<500ms>1000ms
Database latency<100ms>200ms
Cache hit rate>80%<70%
Event throughput>1000/sec<500/sec

Reliability

MetricTargetAlert
Error rate<0.1%>1%
Uptime99.99%<99%
Deploy failures0%>0%

Business

MetricTarget
Events ingestedTrending up
Active usersTrending up
Query volumeTrending up

Request Logging

View worker logs:

wrangler tail

Error Tracking

Monitor errors:

try {
  // Operation
} catch (error) {
  console.error('Error:', {
    message: error.message,
    stack: error.stack,
    context: { requestId, userId, action }
  })
}

Alerts

Set up Cloudflare Page Rules to alert on:

Tracing

Monitor request flow with X-Request-ID:

const requestId = crypto.randomUUID()
// Include in all logs
console.log(`[${requestId}] Request started`)

Database Monitoring

Monitor D1 performance:

# View D1 usage
wrangler d1 list

# Check database status
curl https://api.example.com/api/v1/stats \
  -H "Authorization: Bearer YOUR_API_KEY"

KV Cache Monitoring

Monitor KV usage:

  1. Go to Cloudflare Dashboard
  2. KV → View usage
  3. Monitor:
    • Read requests
    • Write requests
    • Storage used

Next Steps

Last updated: April 3, 2026