Part F – Logging, Metrics and Health
Exam-style hands-on labs with Kong Manager (UI) steps, Admin API / decK / CLI commands, verification and gotchas.
Honest note: the real exam questions are confidential, so nobody can give you the exact ones. These labs are modelled on the published exam objectives (services/routes, upstreams and health checks, consumers and authentication, plugins, traffic control, transformations, logging, workspaces/RBAC, decK/DB-less, hybrid mode, TLS, CLI and troubleshooting) and on the style of tasks you are expected to perform: configure it, then prove it works.
Lab environment and assumptions
| Item | Value |
|---|---|
| Kong Gateway | 3.x (OSS or Enterprise; Enterprise-only labs are marked [EE]) |
| Admin API | http://localhost:8001 |
| Kong Manager | http://localhost:8002 |
| Proxy | http://localhost:8000 (HTTPS :8443) |
| Upstream test app | http://httpbin.org (or a local kong/httpbin / mccutchen/go-httpbin container) |
# Handy aliases used in all labs
export ADMIN=http://localhost:8001
export PROXY=http://localhost:8000
Universal verification checklist (use this on EVERY task)
- Config exists:
curl -s $ADMIN/services | jq,/routes,/plugins,/consumers,/upstreams/<name>/targets. - Traffic test with headers visible:
curl -i ...(never plaincurl– status line and headers are your evidence). - Read the status code:
| Code | Usual Kong meaning |
|---|---|
| 200/2xx | Route matched, upstream answered |
| 400 | Bad request / invalid header / plugin validation |
| 401 | Authentication plugin: missing or invalid credentials |
| 403 | Authenticated but not authorised (ACL, ip-restriction, invalid key scope) |
404 no Route matched with those values | No route matched (path/host/method/header) – the problem is the route |
| 413 | request-size-limiting |
| 429 | rate-limiting |
| 500 | Plugin or Kong internal error – check error.log |
| 502 | Kong reached/parsed upstream badly (connection refused, bad response) |
| 503 | No healthy target / name resolution failed / service unavailable |
| 504 | Upstream timed out (read/send/connect timeout) |
- Useful response headers:
X-Kong-Upstream-Latency,X-Kong-Proxy-Latency,Via: kong/x.y,X-RateLimit-Limit-Minute,X-RateLimit-Remaining-Minute,RateLimit-*,X-Cache-Status,X-Kong-Request-Id. - Logs: default prefix
/usr/local/kong/logs/→error.log,access.log. In Docker:docker logs <kong>. - Declarative / DB-less mode is read-only through the Admin API (POST/PUT/PATCH/DELETE return 405). Change
kong.ymland reload. - Scope matters: a plugin may exist but be attached to a different route/service/consumer than the one you test.
Plugin precedence (most specific wins – only ONE instance of a plugin runs per request)
Consumer + Route + Service → Consumer + Route → Consumer + Service → Route + Service → Consumer → Route → Service → Global.
Lab 41 – file-log
Task: Write one JSON log line per request for orders-route to /tmp/orders.log.
curl -s -X POST $ADMIN/routes/orders-route/plugins --data name=file-log --data config.path=/tmp/orders.log
curl -s $PROXY/anything/log > /dev/null
docker exec -it kong tail -n 1 /tmp/orders.log | jq '{request:.request.url, status:.response.status, latencies, route:.route.name, consumer}'
Keep in mind: the file must be writable by the Kong (kong/nobody) user – permission errors appear only in error.log. Logs contain latencies.kong, latencies.proxy, latencies.request.
Lab 42 – http-log
Task: POST each request log to a collector http://logger:9000/logs.
curl -s -X POST $ADMIN/services/orders-svc/plugins --data name=http-log \
--data config.http_endpoint=http://logger:9000/logs \
--data config.method=POST --data config.queue.max_batch_size=1
Verify: check the collector (or https://webhook.site) after a request; failures log [http-log] ... connection refused in error.log.
Keep in mind: logs are batched/queued – older versions use config.queue_size/flush_timeout, 3.3+ use config.queue.*. Logging plugins run in the log phase, after the response is sent, so they never change the response.
Lab 43 – Prometheus metrics
Task: Enable metrics globally and read them.
curl -s -X POST $ADMIN/plugins --data name=prometheus --data config.per_consumer=true
curl -s $PROXY/anything/m > /dev/null
curl -s $ADMIN/metrics | grep -E '^kong_http_(requests|status)' | head
# Status API (if KONG_STATUS_LISTEN=0.0.0.0:8100)
curl -s http://localhost:8100/metrics | head
Keep in mind: key metrics kong_http_requests_total, kong_latency_bucket, kong_bandwidth_bytes, kong_datastore_reachable. The Status API (status_listen) is the recommended scrape target because it is read-only and can be exposed without exposing the Admin API.
Lab 44 – Node health: /status, /, kong health
Task: Confirm that Kong and its database are healthy and find the version/config.
curl -s $ADMIN/status | jq # connections + database.reachable
curl -s $ADMIN/ | jq '.version, .configuration.database, .configuration.role'
docker exec kong kong health # checks the prefix and nginx pid
curl -s http://localhost:8100/status/ready # Status API readiness (3.x)
Keep in mind: database.reachable=false → check Postgres host/credentials. kong health only checks that processes are running, not that traffic works.