Your API is your product. When response times creep up, error rates spike, or a specific consumer hammers your endpoints, you need to know immediately — not when customers start complaining. This guide shows how to build comprehensive API monitoring with LogTide, from basic request logging to latency percentile tracking and consumer analytics.
The Problem
Most teams start with no API monitoring at all. The first sign of trouble is a customer support ticket: “Your API is slow.”
❌ API monitoring anti-patterns:1. No request logging → "How many requests do we actually get?"2. Average-only metrics → P99 is 10x worse than average, but you can't see it3. No error breakdown → "500 errors are up" -- which endpoint? which consumer?4. No rate limit tracking → Abusive consumers degrade everyone's experience5. No version tracking → Can't tell if v2 is faster than v1
Problem
Business Impact
Undetected latency spikes
Users abandon requests, revenue drops
Silent error rate increase
Data corruption, broken integrations
No consumer visibility
One bad actor degrades service for everyone
Missing audit trail
Cannot debug partner integration issues
The LogTide Approach
Turn every API request into a structured, queryable event:
Implementation
1. Express Request Logging Middleware
A production-ready middleware that captures everything you need:
Ship nginx JSON logs to LogTide with the nginx integration or a log shipper container.
Real-World Example: Fintech API Platform
A fintech company exposes a payments API to 200+ partners, processing 2 million requests per day.
Before LogTide:
Latency SLAs measured only by synthetic checks every 60s
Consumer complaints about slowness took days to investigate
Rate limit violations discovered after the fact
No per-consumer usage analytics for billing
After LogTide:
1. Alert: "p99 latency > 2000ms on POST /v1/payments"2. Query: Recent slow requests route:/v1/payments AND durationMs:>2000 AND time:>30m3. Discovery: 80% of slow requests from consumer "key:a1b2c3d4..." They're sending 500-item batch requests (normal is 10-20)4. Resolution: Contact consumer about batch size limits. Add request body size validation. Total investigation time: 8 minutes
Results:
Latency issues detected in minutes, not days
Per-consumer SLA tracking automated
Rate limit abusers identified proactively
API usage reports generated for billing
Query Patterns for API Monitoring
# Top endpoints by request volumeservice:api AND time:>1h | group by route | count | sort desc# Endpoints with highest error rateservice:api AND time:>1h | group by route | ratio(statusCode:>=500) | sort desc# Slowest endpoints by p99event:api.latency_report AND time:>1h | sort by p99_ms desc# Consumers hitting rate limits mostevent:api.rate_limit_exceeded AND time:>24h | group by consumer | count | sort desc# API version adoptionservice:api AND time:>7d | group by apiVersion | count# Large response payloads (optimization targets)service:api AND responseSize:>1000000 AND time:>24h | group by route | avg(responseSize) | sort desc
Alerting Configuration
# High error rate on any endpoint- name: api-error-rate query: 'service:api AND statusCode:>=500 AND time:>5m' threshold: 50 window: 5m severity: critical# Latency spike- name: api-latency-spike query: 'event:api.latency_report AND p99_ms:>2000' threshold: 1 window: 5m severity: warning# Rate limit abuse- name: api-rate-limit-abuse query: 'event:api.rate_limit_exceeded AND time:>10m' threshold: 100 window: 10m severity: warning# Zero traffic (API may be down)- name: api-zero-traffic query: 'service:api AND time:>5m' threshold: 0 condition: equals window: 5m severity: critical
API Monitoring Checklist
Request Logging
Every request logged with method, path, status, and latency
Route patterns used (not actual paths with IDs) for grouping
Request and response sizes captured
Consumer identity extracted from API key or JWT
API version tracked (header or path-based)
Latency Tracking
High-resolution timing with process.hrtime.bigint()
Percentile reports generated (p50, p95, p99)
Slow request threshold alerts configured
Upstream (nginx) and application latency correlated
Error and Rate Limit Monitoring
Error rates calculated per endpoint
Status code breakdown tracked
Rate limit events logged with consumer identity
Approaching-limit warnings generated
Abuse patterns detectable through queries
Common Pitfalls
1. “Using the actual path instead of the route pattern”
Logging /v1/products/abc123 instead of /v1/products/:id creates thousands of unique “endpoints” that cannot be grouped or analyzed.
Solution: Always use the route pattern from your framework (req.route.path in Express, request.routeOptions.url in Fastify).
2. “Setting alerts on averages”
Average latency of 100ms sounds great. But if p99 is 5000ms, 1% of your users are having a terrible experience.
Solution: Alert on percentiles (p95 or p99), not averages. A p99 spike is often the first sign of a systemic issue.
3. “Only monitoring from the application layer”
Your application may report 200ms latency, but the user experiences 800ms because of TLS handshake, nginx buffering, and network overhead.
Solution: Monitor at both the nginx layer and the application layer. Compare upstream vs. downstream latency to identify infrastructure bottlenecks.
LogTide turns every API request into a structured, queryable event by capturing method, path, status code, latency, consumer identity, and API version. This gives you real-time dashboards, latency percentile reports, and consumer analytics without any per-GB pricing.
Can LogTide track API latency percentiles?
Yes. LogTide supports latency percentile tracking (p50, p95, p99) by aggregating per-route timing data and flushing periodic reports. Because average latency hides outliers, alerting on p99 rather than averages is the recommended approach.
How do I detect which API consumer is abusing rate limits?
LogTide logs every rate-limit event with the consumer identifier extracted from the API key or JWT. You can query across consumers to find who is hitting limits most frequently and correlate those events with downstream latency spikes.
Does LogTide work with Express and Fastify?
LogTide provides ready-made middleware for Express and a plugin for Fastify. Both implementations capture request metadata asynchronously using batched, compressed payloads to minimise performance overhead on your API.