DEV Community

Ezzio Moreira
Ezzio Moreira

Posted on • Updated 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

Top comments (1)

Collapse
 
pedroespindula profile image
Pedro Espíndula

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