API Gateway Traffic Logging and Monitoring

We've seen projects where production starts returning 500s due to a single endpoint overload, and developers spend hours searching through scattered logs for the cause. Without a central entry point—a gateway—you're blind: you can't see who's calling the API, with what latency, which routes are fail

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1282
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1237
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    979
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1027
  • image_website-sbh_0.webp
    Website development for SBH Partners
    1103
  • image_website-_0.webp
    Website development for Red Pear
    552

We've seen projects where production starts returning 500s due to a single endpoint overload, and developers spend hours searching through scattered logs for the cause. Without a central entry point—a gateway—you're blind: you can't see who's calling the API, with what latency, which routes are failing. Configuring logging and traffic monitoring via an API Gateway solves these problems in a couple of days and gives full traffic transparency. Our 10+ years of experience implementing such solutions ensures stability and reduces incident investigation time to 15 minutes—an 87.5% reduction.

We integrate the collection of minimal necessary fields into your gateway: request_id (distributed tracing), consumer_id (client identification), method, path, status_code, latency_ms, request/response sizes. We don't log the request body by default—only in debug mode for selected routes to avoid exposing sensitive data. After implementation, one team cut their incident investigation time from 2 hours to 15 minutes, saving $50,000 per year in engineering hours.

Which metrics are critical for API debugging?

Without centralized collection, you can't quickly answer: which endpoint is the slowest, who generates 90% of errors, why did the upstream fail. We configure the gateway so every request leaves a complete digital trace:

Field Example Purpose
request_id uuid4 Distributed tracing across services
consumer_id client_abc Who made the request
method + path GET /api/v2/orders Endpoint statistics
status_code 429 Error monitoring
latency_ms 143 Performance
upstream_latency_ms 138 Where time is spent
request_size 1024 Traffic anomalies
response_size 4096
ip 1.2.3.4 Security

Each request is also enriched with labels (consumer, route)—enabling slices by client and endpoint.

Risks of logging the request body

In production, the request body contains sensitive data: passwords, tokens, PAN data. We configure the gateway so that the body is logged only for selected routes in debug mode. In Kong this is controlled by the dataTraceEnabled flag, in AWS by a separate config. If a specific request needs debugging, we enable body logging for 15 minutes and then disable it. Kong documentation recommends enabling body logging only when necessary to avoid data leaks. Kong documentation

How distributed tracing works with request_id

request_id is a UUID generated at the gateway and passed to all backend services via the HTTP header X-Request-ID. Each service records its own unique request identifier in logs, allowing a complete picture of a single request execution. To achieve this, simply add the header to all outgoing calls—this is done with middleware in an hour. After that, you can build a "request path" dashboard showing all inter-service calls.

How to configure Kong Gateway for metric collection

Kong is the most popular self-hosted gateway. Logging via the http-log plugin and metrics via prometheus are configured in one config:

plugins: - name: http-log config: http_endpoint: http://logstash:5044/kong method: POST timeout: 1000 keepalive: 1000 flush_timeout: 2 retry_count: 10 queue: max_batch_size: 200 max_coalescing_delay: 1 max_entries: 10000 - name: prometheus config: per_consumer: true status_code_metrics: true latency_metrics: true bandwidth_metrics: true upstream_health_metrics: true 

After that, /metrics on Kong Manager returns all metrics in Prometheus format. Scrape interval: 15 seconds.

Configuration in AWS API Gateway

In AWS, logging is configured at the Stage level via CloudWatch:

{ "loggingLevel": "INFO", "dataTraceEnabled": false, "metricsEnabled": true, "accessLogDestinationArn": "arn:aws:logs:us-east-1:123456789:log-group:api-gateway-access", "accessLogFormat": "{\"requestId\":\"$context.requestId\",\"ip\":\"$context.identity.sourceIp\",\"caller\":\"$context.identity.caller\",\"user\":\"$context.identity.user\",\"requestTime\":\"$context.requestTime\",\"httpMethod\":\"$context.httpMethod\",\"resourcePath\":\"$context.resourcePath\",\"status\":\"$context.status\",\"protocol\":\"$context.protocol\",\"responseLength\":\"$context.responseLength\",\"integrationLatency\":\"$context.integrationLatency\",\"responseLatency\":\"$context.responseLatency\"}" } 

dataTraceEnabled: false—never enable in production, it logs request bodies. CloudWatch Insights query for p95 latency by endpoint:

fields @timestamp, resourcePath, responseLatency | filter status >= 200 | stats pct(responseLatency, 95) as p95 by resourcePath | sort p95 desc | limit 20 

Nginx API Gateway + OpenTelemetry

If the gateway is on Nginx (nginx-plus or OpenResty), logging is configured via log_format:

log_format api_json escape=json '{' '"timestamp":"$time_iso8601",' '"request_id":"$request_id",' '"method":"$request_method",' '"path":"$uri",' '"status":$status,' '"latency_ms":$request_time,' '"upstream_latency_ms":"$upstream_response_time",' '"bytes_sent":$bytes_sent,' '"consumer":"$http_x_consumer_id",' '"ip":"$remote_addr"' '}'; access_log /var/log/nginx/api_access.log api_json buffer=32k flush=5s; 

For distributed tracing, use opentelemetry-nginx-module—we plug it in as needed.

Which visualization stack to choose: ELK or Grafana?

Criterion ELK (Elasticsearch, Logstash, Kibana) Grafana Stack (Loki, Prometheus, Grafana)
Log storage Indexes all fields—expensive Stores compressed logs without indexing—cheap
Log search Full-text, fast Limited (by labels)
Metrics Only via beats Prometheus—native
Setup complexity High (Logstash pipeline) Medium (PromQL, LogQL)
Typical cost for 100 GB/day $200–400/month $50–100/month

For most projects, Grafana Stack is easier to operate and 2-4 times cheaper than ELK. It also offers better integration with Prometheus and OpenTelemetry. ELK is justified when complex log searching is needed (incident analysis, retrospection). Using Loki instead of Elasticsearch can reduce storage costs by up to 75%.

Alerting

Minimum alert set (Prometheus AlertManager / Grafana Alerting) — Prometheus AlertManager is more efficient than traditional logging-based alerting for real-time metrics:

- alert: APIHighErrorRate expr: | sum(rate(kong_http_requests_total{status=~"5.."}[5m])) / sum(rate(kong_http_requests_total[5m])) > 0.05 for: 2m labels: severity: critical annotations: summary: "Error rate > 5% over the last 5 minutes" - alert: APIHighLatency expr: | histogram_quantile(0.95, sum(rate(kong_request_latency_ms_bucket[5m])) by (le, route) ) > 2000 for: 5m labels: severity: warning annotations: summary: "p95 latency > 2s for route {{ $labels.route }}" 
Common mistakes in logging configuration - Forgetting to enable `request_id`—losing distributed tracing. - Enabling `dataTraceEnabled` in production—data leaks and increased storage cost. - Not configuring log rotation—disk overflow. - Not testing alerts on staging—false positives in production.

Work process and what's included in the result

  1. Analytics: we study your API architecture, current gateways, traffic volume, storage requirements. We handle up to 100,000 req/s.
  2. Design: choose the stack (Kong/AWS/Nginx), define logging schema, set retention to 30 days.
  3. Implementation: deploy gateway with plugins, configure metric collection, connect Logstash/Loki. We guarantee configuration correctness.
  4. Testing: verify log correctness, simulate errors, test alerts.
  5. Deployment: publish configuration, train the team on dashboards.

In the end you get:

  • Documentation on logging schema and fields.
  • Dashboard access (Grafana/Kibana) for each team member.
  • Configured alerts on critical metrics.
  • Team training: how to read logs, how to respond to alerts.
  • 2 weeks of support after launch.

Implementation timeline

Basic logging and dashboards: 2–3 days. Full stack with alerting, tracing, and retrospective analysis: 1–2 weeks depending on infrastructure maturity.

We'll assess your project and propose an optimal configuration in 1–2 days. Contact us for a gateway audit—we'll prepare the architecture and send an example configuration. Get a consultation on setting up your API gateway monitoring right now.