DEV Community

Ezzio Moreira
Ezzio Moreira

Posted on • Edited on

Observability in Kong API Gateway

This article explains some points about monitoring and observability of the Kong API Gateway system through the three pillars of observability: metrics, trace, and logs.

Metrics

Kong has the Prometheus plugin, which exports service metrics through the endpoint http://endpoint-kong:8001/metrics. These metrics provide insight into the performance of the service.

To configure metric collection: https://docs.konghq.com/hub/kong-inc/prometheus/

Image description

Trace

Kong has the OpenTelemetry plugin, which sends trace and spans generated by the service to an HTTP or gRPC endpoint of the OpenTelemetry collector. The OpenTelemetry collector receives this data, processes it, and sends it to the vendor for observability.

It is necessary to declare the environment variable KONG_OPENTELEMETRY_TRACING: all, to enable OTEL tracing on Kong, another imported variable is KONG_OPENTELEMETRY_TRACING_SAMPLING_RATE: 1.0, which defines the proportion of traces sample collected and sent to the vendor of observability.

To configure trace collection: https://docs.konghq.com/hub/kong-inc/opentelemetry/

Image description

Logs

Kong offers many plugins for collecting, processing, and sending logs. I can recommend using a Fluentbit sidecar for collecting these logs and send to an observability provider.

It is possible to use the NGINX HTTP logs module to help us define which attributes will be added to the logs.

Module ngx_http_log_module: http://nginx.org/en/docs/http/ngx_http_log_module.html

To configure logs collection: https://docs.konghq.com/hub/?category=logging

Image description

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (1)

Collapse
 
pedroespindula profile image
Pedro Espíndula

Great article, @ezziomoreira! Congrats! It helped me a lot on instrumenting Kong!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more