# Kong

> Send distributed traces from Kong to Last9 using OpenTelemetry

Source: https://last9.io/docs/integrations/edge-and-gateway/kong/

This guide will help you integrate [Kong](https://konghq.com/) with Last9 to monitor and improve the observability of your API gateway. This document provides step by step instructions to start collecting traces using Kong's OpenTelemetry plugin.

## Prerequisites

1. Kong (version 2.0 or above)
2. Last9 OpenTelemetry endpoint credentials from the [Integrations](https://app.last9.io/integrations?integration=OpenTelemetry) page
   - `levitate_otlp_endpoint`
   - `levitate_otlp_auth_header`

## Enable Distributed Tracing in Kong

1. **Enable tracing instrumentation**

   Set the environment variable `KONG_TRACING_INSTRUMENTATIONS="all"` and restart Kong. More Kong configuration options available [here](https://docs.konghq.com/gateway/3.7.x/reference/configuration/#tracing_instrumentations).

2. **Enable the OpenTelemetry Plugin**

   Add the OpenTelemetry plugin to your Kong configuration file or enable it via the Admin API. Here’s an example of how to enable the plugin globally via the Kong Admin API:

   ```bash
   curl -i -X POST http://<kong-admin-url>:8001/plugins \
    --data "name=opentelemetry" \
    --data "config.endpoint=http://<levitate_otlp_endpoint>" \
    --data "config.headers.Authorization=<levitate_otlp_auth_header>" \
    --data "config.service_name=kong"
   ```

   :::note
   The `opentelemetry` plugin sends trace to an OpenTelemetry compatible backend such as Last9.
   :::

3. **Verify the Plugin is Enabled**

   You can verify that the plugin is enabled by checking the Kong logs for trace data being sent to Last9.

   :::tip
   Set environment variable `KONG_LOG_LEVEL="debug"` to verify traces are flowing in correctly to Last9 if needed.
   :::

## Verify Traces in Last9

![Kong Traces in Last9 via OpenTelemetry](../../../../../assets/content/docs/integrations/edge-and-gateway/kong/kong-traces.png)

- Log in to your Last9 account and navigate to the Grafana dashboard
- Navigate to the traces dashboard to see the traces collected from Kong. You should see traces corresponding to your API requests, with detailed information about the request flow and latency

---

## Troubleshooting

Please get in touch with us on [Discord](https://discord.com/invite/Q3p2EEucx9) or [Email](mailto:support@last9.io) if you have any questions.
