Skip to main content

Introduction

Tyk Gateway produces three observability signals: structured logs, distributed traces, and metrics. It exports traces and metrics through the OpenTelemetry Protocol (OTLP), and writes logs as structured JSON that an OpenTelemetry Collector collects. This guide shows you how to enable each signal and route them to a local Grafana stack (Prometheus, Loki, Tempo). By the end of this guide you will have:
  • Structured JSON access logs from Tyk Gateway shipping to Loki
  • Distributed traces exporting to Tempo
  • Metrics (request rate, latency, error rate) flowing to Prometheus
  • A Grafana instance wired up to all three backends
  • Optionally, metrics from Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal in the same Prometheus instance

Availability

OTLP metrics for Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal have their own minimum versions: v5.16.0, v2.14.0, and v1.20.0 respectively.

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. The control plane components can also send their metrics to the same Collector. See Add Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal.
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 Data Sources

Create grafana/provisioning/datasources/tyk.yaml:

Step 4: Start and Verify

Restart your deployment to apply the configuration changes to Tyk Gateway and bring up the new services:
Send test requests through the 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. Grafana Explore showing tyk_api_requests_total request counts rising Logs: in Explore, select the Loki datasource and run:
You should see structured access log entries with fields such as 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 Tyk Gateway can reach otel-collector:4317. Check the OTel Collector logs with docker compose logs otel-collector for any connection errors.

Add Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal

This section is optional. If you only need Tyk Gateway metrics, skip to Use the Example Grafana Dashboards and Alert Rules. Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal export metrics with the same opentelemetry.metrics configuration pattern as Tyk Gateway. For Tyk Developer Portal, the block is OpenTelemetry.Metrics. This section adds all three components to the same Docker Compose deployment and points them at the same OTel Collector. The metrics from all four components then go to the Prometheus instance from Step 3. Each component exports all of its metric families by default. To turn off a family, see Metric Family Flags.
The Tyk Developer Portal configuration file uses PascalCase keys for all settings, not only for OpenTelemetry. Tyk Dashboard and Tyk MDCB use lowercase keys. Each component follows its own native pattern.

Configure Tyk Dashboard

Add the following environment variables to your tyk-dashboard service:
If you prefer tyk_analytics.conf, the equivalent configuration is:
Leave control_plane_id blank to generate it automatically and share it with Tyk MDCB through Redis. If you run more than one control plane, set it explicitly.

Configure Tyk MDCB

Add the following environment variables to your tyk-sink service:
If you prefer tyk_sink.conf, the equivalent configuration is:

Configure Tyk Developer Portal

Add the following environment variables to your tyk-portal service:
The TYK_PORTAL_* equivalents of these variables also work. If you prefer portal.conf, the equivalent configuration is:

Verify the Control Plane Metrics

In Grafana Explore, select the Prometheus data source and run:
After each component completes at least one export cycle, you should see series for Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal. Grafana Explore with the Prometheus data source running the control plane query, showing Tyk Dashboard series with the control_plane_id and deployment_environment labels

Use the Example Grafana Dashboards and Alert Rules

Tyk provides example Grafana dashboards and alert rules for the OpenTelemetry metrics that Tyk components export. Use them to get started quickly, without building panels or rules from scratch.

Get the Examples

The examples are in the observability folder of the public Tyk Install repository. The README in the folder explains how to add OpenTelemetry to a new Tyk installation and to an existing one.

Example Dashboards

These Tyk Gateway dashboards work with the setup from the Instructions:
  • Tyk Gateway - Fleet Health
  • Tyk Gateway - API Portfolio Overview
  • Tyk Gateway - API Troubleshooting
  • Tyk Gateway - API SLOs
  • Tyk Gateway - Native OTLP Metrics
  • Tyk Gateway - MCP Metrics
If you added Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal, you can also use the control plane dashboards. Tyk Environments Overview shows all your environments in one place. For each environment, you can see each control plane and the health, version, and connectivity of every component in it. From the overview, go into more detail with a dashboard for each component:
  • Tyk Dashboard
  • Tyk MDCB
  • Tyk Developer Portal
Tyk Environments Overview dashboard in Grafana showing an environment with its control plane, dependency checks, gateway version drift, and license expiry Each dashboard is a single JSON file. To use one, copy the JSON and import it into Grafana as a dashboard. To find the dashboards after you import them, filter by the tyk tag.

Example Alert Rules

The examples also include alert rules for the control plane and its components. They need the control plane metrics:
  • Control plane: a component stops reporting metrics, a component restarts, or memory use is above 90% of the memory limit (when a limit is set)
  • Tyk Dashboard: a dependency is unhealthy, the API error rate or latency is high, a gateway stops sending heartbeats, or fewer gateways are connected than 15 minutes ago
  • Tyk MDCB: a dependency is unhealthy, a Data Plane group has no connected gateways or loses gateways, gateways reconnect repeatedly or fail to connect, a gateway stops sending heartbeats, gateways in a group load different API counts or run different versions, the RPC error rate is high, the metrics exporter fails, or the license or a certificate is about to expire
  • Tyk Developer Portal: a dependency is unhealthy, the portal cannot reach a provider, or a provider sync is stale, failing, or slow
Each alert has a severity label (critical, warning, or info) and a tyk_component label. The thresholds are starting points. Adjust them for your deployment. The rules are grouped by component: tyk-control-plane, tyk-dashboard, tyk-mdcb, and tyk-portal. Grafana Alert rules page listing the Tyk control plane rule file with the tyk-control-plane group expanded, and the tyk-dashboard, tyk-mdcb, and tyk-portal groups The alert rules are Prometheus-format YAML files. To use them, import them into Grafana-managed alert rules:
1

Open the Alert Rules

In Grafana, go to Alerting > Alert rules.
2

Start the Import

In the data source-managed alert rules section, select Import to Grafana-managed rules.
3

Upload the Rule File

Select Prometheus YAML file as the import source and upload the rule file.
4

Import the Rules

Select the data source that the rules query, then select Import.
For all options and limitations, see Import data source-managed rules to Grafana-managed rules in the Grafana documentation.
These examples are built for Grafana. Because Tyk exports metrics with OpenTelemetry, you can use any observability backend. If you use a different backend, use the examples as a reference for which metrics to chart.

Next Steps

  • Explore default metrics: see all Tyk Gateway metrics available out of the box in Default Metrics
  • Add custom metrics: attach request headers, JWT claims, and response codes as metric dimensions using Custom Metrics
  • Kubernetes deployment: for log collection in Kubernetes using the OTel Collector DaemonSet, see Collecting Gateway Logs with OTel on Kubernetes
  • Explore control plane metrics: see the full Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal reference in Default Metrics
  • Understand control plane correlation: learn how control_plane_id lets Tyk Dashboard and Tyk MDCB metrics correlate in Metrics Concepts