Integration Guide - Tyk API Gateway

Introduction

The Tyk plugin for Moesif captures API traffic from Tyk API Gateway and sends to Moesif. This is done via the Tyk Analytics Pump which is an open source component that handles sending API logs to Moesif in an asynchronous way.

For an overview on how the plugin works and use cases, see Tyk + Moesif: the perfect pairing on Tyk’s blog.

Setup

Moesif recommends Tyk Pump v1.1.0 or later for enhanced user tracking and sampling features. The Moesif Tyk integration automatically maps a Tyk Token Alias to a user in Moesif.

  1. Follow Tyk’s setup instructions to get a Tyk Gateway instance running. You will also need to set up a Tyk Pump instance, if you haven’t already. Here is the guide for Ubuntu

  2. Create a pump.conf to configure the Tyk Analytics Pump and add Moesif as a backend:

{
	"pumps": {
		"moesif": {
			"name": "moesif",
			"meta": {
				"application_id": "Your Moesif Application Id"
			}
		},
	}
}

You can find your Application Id from Moesif Dashboard -> Top Right Menu -> Installation -> Tyk API Gateway

  1. Ensure analytics is enabled You should ensure detailed analytics recording is enabled in your tyk.conf file.
"enable_analytics" : true,
"analytics_config": {
  "enable_detailed_recording": true
}

Once your config changes are done, you may need to reload your Tyk Pump and Tyk Gateway instances.

Configuration options

The Tyk Pump for Moesif has a few configuration options:

Parameter Required? Description
application_id required Moesif Application Id. Multiple Tyk api_id’s will be logged under the same app id.
request_header_masks optional Mask a specific request header field. Type: String Array [] string
request_body_masks optional Mask a specific - request body field. Type: String Array [] string
response_header_masks optional Mask a specific response header field. Type: String Array [] string
response_body_masks optional Mask a specific response body field. Type: String Array [] string
disable_capture_request_body optional Disable logging of request body. Type: Boolean. Default value is false.
disable_capture_response_body optional Disable logging of response body. Type: Boolean. Default value is false.
user_id_header optional Field name to identify User from a request or response header. Type: String.
company_id_header optional Field name to identify Company (Account) from a request or response header. Type: String.

Updated: