Skip to main content

Introduction

Tyk Gateway exports all three observability signals (structured logs, distributed traces, and metrics) via the OpenTelemetry Protocol (OTLP). This guide shows you how to enable each signal and route them to a local Grafana stack (Prometheus, Loki, Tempo) using an OpenTelemetry Collector. By the end of this guide you will have:
  • Structured JSON access logs from Tyk Gateway shipping to Loki
  • Distributed traces exporting to Tempo
  • Gateway metrics (request rate, latency, error rate) flowing to Prometheus
  • A Grafana instance wired up to all three backends

Availability

Prerequisites

Architecture

All three signals flow from Tyk Gateway to a single OpenTelemetry Collector endpoint. The Collector fans them out to the appropriate backend. Grafana queries all three.
Tyk Gateway does not export logs via OTLP. It writes structured JSON to stderr. The OTel Collector reads those logs from the Docker container log path using the filelog receiver.

Instructions

Step 1: Configure Tyk Gateway

Add the following environment variables to your tyk-gateway service. These enable all three signals:
If you prefer tyk.conf, the equivalent configuration is:
sampling.rate: 1.0 captures every request, which is suitable for getting started. In production, lower this to 0.1 (10%) or use ParentBased sampling. See the Tyk Gateway configuration reference for all options.

Step 2: Add the OTel Collector

Create an otelcol-config.yml file in your deployment directory:
Then add the otel-collector service to your docker-compose.yml:
The volume mounts give the Collector read access to Docker container logs for the filelog receiver.

Step 3: Add the Grafana stack

Add Prometheus, Loki, Tempo, and Grafana to your docker-compose.yml:
Grafana is mapped to port 3001 to avoid conflicting with Tyk Dashboard on port 3000. Adjust if needed.
Create a minimal prometheus.yml to allow OTLP ingest:
Create a minimal tempo.yaml:

Provision Grafana datasources

Create grafana/provisioning/datasources/tyk.yaml:

Step 4: Start and verify

Restart your deployment to apply the configuration changes to your Gateway and bring up the new services:
Send test requests through Tyk Gateway, then open Grafana at http://localhost:3001 and verify each signal.
If you are following this guide using the Tyk Self-Managed getting started setup, an httpbingo API is pre-configured. Generate test traffic with:
Metrics: in Explore, select the Prometheus datasource and run:
You should see request counts rise as traffic flows through the Gateway. Metrics in Grafana Logs: in Explore, select the Loki datasource and run:
You should see structured access log entries with fields like api_id, path, status, latency_total, and trace_id. Logs in Grafana Traces: in Explore, select the Tempo datasource and search for recent traces. Each trace should show one span for the request. Traces in Grafana
If traces are not appearing, verify that TYK_GW_OPENTELEMETRY_TRACES_ENABLED=true is set and that the Gateway can reach otel-collector:4317. Check the OTel Collector logs with docker compose logs otel-collector for any connection errors.

Next steps