DEV Community

ANKUSH CHOUDHARY JOHAL
ANKUSH CHOUDHARY JOHAL

Posted on • Originally published at johal.in

Retrospective: Migrating from Nginx to Kong 3.0 Improved API Observability 40%

Retrospective: Migrating from Nginx to Kong 3.0 Improved API Observability 40%

A deep dive into our team’s journey replacing Nginx with Kong 3.0, and how native observability features delivered a 40% boost in API visibility.

Background: The Nginx Observability Gap

Our team manages 120+ internal and external APIs, all routed through a fleet of Nginx reverse proxies. For years, Nginx served us well for basic routing, SSL termination, and rate limiting. But as our API ecosystem grew, we hit critical observability limitations:

  • Disjointed logging: Nginx access logs required custom parsing to extract API-specific metadata (consumer ID, endpoint version, error codes), leading to delays in troubleshooting.
  • No native metrics: We relied on third-party exporters to pull Nginx status metrics, which lacked granularity for per-API request volume, latency, and error rates.
  • Manual instrumentation: Adding observability for new APIs required editing Nginx configs and redeploying, creating a bottleneck for the DevOps team.
  • Trace gaps: Distributed tracing required injecting headers manually, with frequent breaks in trace chains across microservices.

By Q3 2023, our mean time to resolve (MTTR) API incidents had crept up to 47 minutes, with 60% of that time spent gathering observability data. We needed a solution that integrated observability natively, without custom tooling.

Why Kong 3.0?

We evaluated several API gateways, but Kong 3.0 stood out for three key reasons:

  • Native observability plugins: Kong’s plugin ecosystem includes pre-built tools for logging (HTTP, TCP, Syslog), metrics (Prometheus, StatsD), and tracing (OpenTelemetry, Zipkin) with zero custom code.
  • Compatibility: Kong is built on OpenResty (like Nginx), so migrating our existing Nginx configs required minimal changes to routing rules and SSL setups.
  • Performance: Kong 3.0’s optimized request handling added less than 2ms of latency per request, well within our SLA requirements.

We set a goal to complete migration for all production APIs within 3 months, with a target of 30% improved observability. We exceeded that, hitting 40% — here’s how.

Migration Strategy

We followed a phased approach to minimize risk:

  1. Assessment: Audited all Nginx configs, mapped 120+ API routes, and identified 18 custom Nginx Lua scripts that needed conversion to Kong plugins.
  2. Staging Validation: Deployed Kong 3.0 in a staging environment, replicated production traffic via shadowing, and validated routing, SSL, and rate limiting behavior.
  3. Plugin Configuration: Enabled three core observability plugins for all APIs:
    • opentelemetry: Automatically injects trace headers and exports spans to our Jaeger backend.
    • prometheus: Exposes per-API metrics for request count, latency (p50, p95, p99), and 4xx/5xx error rates.
    • http-log: Streams structured JSON logs to our ELK stack, including consumer ID, API version, and upstream response time.
  4. Gradual Rollout: Migrated APIs in batches of 10, starting with low-traffic internal APIs, then moving to external customer-facing APIs. Used DNS weighting to shift 10% of traffic at a time, monitoring error rates and latency throughout.
  5. Decommission: Retired Nginx nodes after 2 weeks of zero traffic post-migration.

Results: 40% Improvement in API Observability

We measured observability improvement using a custom score that weighted four factors: metric granularity (30%), log structure (25%), trace completeness (25%), and time to access data (20%). Pre-migration, our score was 62/100. Post-migration, it jumped to 87/100 — a 40% improvement.

Key quantitative results:

  • MTTR for API incidents dropped from 47 minutes to 28 minutes (40% reduction).
  • Trace completeness improved from 68% to 99% — no more broken trace chains.
  • Log parsing time decreased from 12 minutes per incident to 0: logs are structured JSON, so our ELK stack indexes them automatically.
  • Per-API metrics are now available in real time, with no manual configuration required for new APIs.

We also saw unexpected benefits: Kong’s rate limiting and authentication plugins replaced 12 custom Nginx Lua scripts, reducing our config footprint by 35%.

Lessons Learned

No migration is without challenges. We hit two major roadblocks:

  1. Plugin conflicts: Initial testing revealed that the opentelemetry and prometheus plugins had conflicting header injection rules. We resolved this by updating to Kong 3.0.1, which included a fix for the conflict.
  2. Traffic shadowing overhead: Shadowing production traffic to staging added 15% CPU load to our Kong nodes. We reduced this by sampling 10% of traffic for shadowing instead of 100%.

Our top tip for teams planning a similar migration: start with observability plugin configuration early. We initially treated plugins as an afterthought, which delayed our staging validation by 2 weeks.

Conclusion

Migrating from Nginx to Kong 3.0 was a net win for our team. The 40% boost in API observability reduced incident resolution time, eliminated custom tooling, and laid the groundwork for future API governance initiatives. For teams outgrowing Nginx’s basic observability features, Kong 3.0 offers a low-latency, compatible upgrade path with massive observability gains.

Top comments (0)