Datadog can collect and display errors, response time, duration, latency, as well as monitor the performance of API traffic in Tyk to discover issues in your APIs or consumers.
Tyk has a built-in Datadog integration that collects metrics from Tyk API gateway.
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
Tyk pump writes custom application metrics and sends them into Datadog by sending them to DogStatsD, 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.
This example was taken from Tyk-demo 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
Tyk’s integration uses DogstatsD. 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
For the Datadog Agent to connect the DD portal. Your API key can be found in Account Settings.
Sets the environment name.
Additional tags to append to all metrics, events, and service checks received by this DogStatsD server.
Enables log collection for the Datadog Agent.
Collects logs from containers.
Path to the Unix socket to listen to. Docker compose mounts this path.
Enables container detection and tagging for Unix socket metrics.
Listens for DogStatsD packets from other containers. (Required to send custom metrics).
Name of the agent host in Docker.
Excludes Datadog redis checks. (Optional)
Excludes docker checks for the Datadog Agent.
After setting environment variables listed above, set up the agent with DogstatsD.
Create a dashboard or import the sample 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.
the 95th percentile of request time values in the time interval Shown as millisecond
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
Represents the average of request time values in the time interval Shown as millisecond
Represents the maximum value of request time values sent during the time interval Shown as millisecond
Represents the median of request time values in the time interval Shown as millisecond
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 the above dashboard and use it as an example or baseline for your own dashboard.
The Tyk integration does not include any events.
The Tyk integration does not include any service checks.