Seeing what the gateway sees

Kong Course · lesson 12 of 15 · 4 min read

The gateway is the one place that sees every request - use it.

Open this lesson in the learning hub

Key points

  • Every request passes through Kong, so it is the natural place to measure latency, status and volume.
  • The prometheus plugin exposes per-route metrics with no change to any service.
  • Correlation-id generates a request id and passes it upstream, so one id follows a call across services.
  • Logging plugins run in the log phase, after the client has its response - so they add no latency.
  • Watch upstream latency and Kong latency separately: they point at completely different problems.

Example

plugins:
  - name: prometheus
    config: { status_code_metrics: true, latency_metrics: true }

  - name: correlation-id
    config:
      header_name: X-Request-Id
      generator: uuid
      echo_downstream: true

  - name: http-log            # runs in the log phase - off the request path
    config: { http_endpoint: http://logstash:8080 }

Split gateway latency from upstream latency, or you will scale the wrong thing.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Kong Course course, and every lesson in it is listed on the Kong Course contents page.