---
title: Tyk
description: Track requests with time statistics sliced by resp-code, api, path, oauth etc.
breadcrumbs: Docs > Integrations > Tyk
---

# Tyk
Supported OS 
## Overview{% #overview %}

Datadog can collect and display errors, response time, duration, latency, as well as monitor the performance of API traffic in [Tyk](https://tyk.io/) to discover issues in your APIs or consumers.

Tyk has a built-in Datadog integration that collects metrics from [Tyk API gateway](https://github.com/TykTechnologies/tyk).

Tyk API gateway records all the traffic that it's processing. It sends that information to Datadog and builds dashboards around it.

### How it works{% #how-it-works %}

[Tyk pump](https://tyk.io/docs/tyk-pump/) writes custom application metrics and sends them into Datadog by sending them to [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd.md?tab=hostagent#pagetitle), a metrics aggregation service bundled with the Datadog Agent. DogStatsD implements the StatsD protocol which adds a few Datadog-specific extensions including the Histogram metric type, that is in use by `Tyk-gateway`.

`Tyk-gateway` uses `Tyk-pump` to send the analytics it generated to Datadog.

When running the Datadog Agent, DogstatsD gets the `request_time` metric from `Tyk-pump` in real time, per request, so you can understand the usage of your APIs and get the flexibility of aggregating by various parameters such as date, version, returned code, method etc.

The custom metric Tyk is using is of type [DD_HISTOGRAM_AGGREGATES](https://docs.datadoghq.com/agent/docker.md?tab=standard#dogstatsd-custom-metrics).

## Setup{% #setup %}

Tyk's integration is included in the `tyk-pump` package, so you only need to set configuration in the `pump.conf` (and there's no need to install anything on your Tyk platform).

### Installation{% #installation %}

#### Installation{% #installation-1 %}

For this integration you need to have a running Tyk installation. You can install [Tyk self managed](https://tyk.io/docs/tyk-self-managed/install/) or [Tyk OSS](https://tyk.io/docs/apim/open-source/installation/). Both options include the `tyk-pump`.

#### Install Datadog Agent{% #install-datadog-agent %}

Install the [Datadog Agent](https://app.datadoghq.com/account/settings/agent/latest) in your environment.

Run the Datadog [Agent](https://docs.datadoghq.com/agent.md) in your K8s cluster, as a Docker container, on your Mac, or any way as long as `Tyk pump` is able to access it.

For containerized environments, see the [Autodiscovery Integration Templates](https://docs.datadoghq.com/agent/kubernetes/integrations.md) for more guidance. To validate that the changes are applied, [run the Agent's status subcommands](https://docs.datadoghq.com/agent/guide/agent-commands.md?tab=agentv6v7#agent-status-and-information)

### Configuration{% #configuration %}

#### Tyk-pump{% #tyk-pump %}

To set a Datadog pump follow the instructions in [the DogstatsD section](https://github.com/TykTechnologies/tyk-pump#dogstatsd) of the pump README.

The following is an example of Datadog pump configuration in `pump.conf`:

```json
pump.conf:
...
   "dogstatsd": {
      "type": "dogstatsd",
      "meta": {
        "address": "dd-agent:8125",
        "namespace": "tyk",
        "async_uds": true,
        "async_uds_write_timeout_seconds": 2,
        "buffered": true,
        "buffered_max_messages": 32,
        "sample_rate": 0.9999999999,
        "tags": [
          "method",
          "response_code",
          "api_version",
          "api_name",
          "api_id",
          "org_id",
          "tracked",
          "path",
          "oauth_id"
        ]
      }
    },
```

This [example](https://github.com/TykTechnologies/tyk-demo/blob/master/deployments/analytics-datadog/volumes/tyk-pump/pump-datadog.conf) was taken from [Tyk-demo](https://github.com/TykTechnologies/tyk-demo/tree/master/deployments/analytics-datadog) project, an open source project that spins up a full Tyk platform in one command and offers ready-made examples, including the Datadog example. To run this integration, use `up.sh analytics-datadog`.

#### Setup Datadog Agent{% #setup-datadog-agent %}

Tyk's integration uses [DogstatsD](https://docs.datadoghq.com/developers/dogstatsd.md?tab=hostagent#setup). It is a metrics aggregation service bundled with the Datadog Agent. DogStatsD implements the `StatsD` protocol and adds a few Datadog-specific extensions. Tyk is using `Histogram metric type`.

Set up the following Datadog and DogStatsD environment variables in your environment:

| DD Environment variable              | Value                  | Description                                                                                                                                                |
| ------------------------------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| DD_API_KEY                           | {your-datadog-api-key} | For the Datadog Agent to connect the DD portal. Your API key can be found in [Account Settings](https://app.datadoghq.com/organization-settings/api-keys). |
| DD_ENV                               | tyk-demo-env           | Sets the environment name.                                                                                                                                 |
| DD_DOGSTATSD_TAGS                    | "env:tyk-demo"         | Additional tags to append to all metrics, events, and service checks received by this DogStatsD server.                                                    |
| DD_LOGS_ENABLED                      | true                   | Enables log collection for the Datadog Agent.                                                                                                              |
| DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL | true                   | Collects logs from containers.                                                                                                                             |
| DD_DOGSTATSD_SOCKET                  | /var/run/docker.sock   | Path to the Unix socket to listen to. Docker compose mounts this path.                                                                                     |
| DD_DOGSTATSD_ORIGIN_DETECTION        | true                   | Enables container detection and tagging for Unix socket metrics.                                                                                           |
| DD_DOGSTATSD_NON_LOCAL_TRAFFIC       | true                   | Listens for DogStatsD packets from other containers. (Required to send custom metrics).                                                                    |
| DD_AGENT_HOST                        | dd-agent               | Name of the agent host in Docker.                                                                                                                          |
| DD_AC_EXCLUDE                        | redis                  | Excludes Datadog redis checks. (Optional)                                                                                                                  |
| DD_CONTAINER_EXCLUDE                 | true                   | Excludes docker checks for the Datadog Agent.                                                                                                              |

After setting environment variables listed above, set up the agent [with DogstatsD](https://docs.datadoghq.com/developers/dogstatsd.md?tab=hostagent#how-it-works).

[Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands.md#start-stop-and-restart-the-agent) after setup.

### Validation{% #validation %}

Create a dashboard or import [the sample](https://github.com/DataDog/integrations-extras/blob/master/tyk/assets/dashboards/tyk_analytics_canvas.json) and add a widget. In the section **Graph your data** under the **metric** option, start typing the namespace you chose for the pump in the config `pump.conf` under `dogstatsd.namespace`.

In the example above, it's `tyk`. Once you start typing, all the available metrics are displayed.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **tyk.request\_time.95percentile**(gauge) | the 95th percentile of request time values in the time interval*Shown as millisecond*                                                                                                                                                          |
| **tyk.request\_time.count**(rate)         | Represents the number of values submitted during the interval. Represents the number of values submitted during the interval, X. The Agent submits this number as a RATE so it would show in app the value of X/interval*Shown as millisecond* |
| **tyk.request\_time.avg**(gauge)          | Represents the average of request time values in the time interval*Shown as millisecond*                                                                                                                                                       |
| **tyk.request\_time.max**(gauge)          | Represents the maximum value of request time values sent during the time interval*Shown as millisecond*                                                                                                                                        |
| **tyk.request\_time.median**(gauge)       | Represents the median of request time values in the time interval*Shown as millisecond*                                                                                                                                                        |

### Dashboards{% #dashboards %}

With Datadog, you can create dashboards that display statistics about your API services and their consumption.

Here's an example for such a dashboard:



**Note: You can [import](https://github.com/DataDog/integrations-extras/blob/master/tyk/assets/dashboards/tyk_analytics_canvas.json) the above dashboard and use it as an example or baseline for your own dashboard.**

### Events{% #events %}

The Tyk integration does not include any events.

### Service Checks{% #service-checks %}

The Tyk integration does not include any service checks.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).
