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 or update your pump.env to configure the Tyk Analytics Pump and add Moesif as a backend:

TYK_PMP_PUMPS_MOESIF_TYPE=moesif
TYK_PMP_PUMPS_MOESIF_META_APPLICATIONID=your_moesif_application_id

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

  1. Ensure analytics is enabled You should ensure detailed analytics recording is enabled in your tyk.env file.
TYK_GW_ENABLEANALYTICS=true
TYK_GW_ANALYTICSCONFIG_ENABLEDETAILEDRECORDING=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 Environment Variable Name
application_id required Moesif Application Id. Multiple Tyk api_id’s will be logged under the same app id. TYK_PMP_PUMPS_MOESIF_META_APPLICATIONID
request_header_masks optional Mask a specific request header field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_REQUESTHEADERMASKS
request_body_masks optional Mask a specific - request body field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_REQUESTBODYMASKS
response_header_masks optional Mask a specific response header field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_RESPONSEHEADERMASKS
response_body_masks optional Mask a specific response body field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_RESPONSEBODYMASKS
disable_capture_request_body optional Disable logging of request body. Type: Boolean. Default value is false. TYK_PMP_PUMPS_MOESIF_META_DISABLECAPTUREREQUESTBODY
disable_capture_response_body optional Disable logging of response body. Type: Boolean. Default value is false. TYK_PMP_PUMPS_MOESIF_META_DISABLECAPTURERESPONSEBODY
user_id_header optional Field name to identify User from a request or response header. Type: String. TYK_PMP_PUMPS_MOESIF_META_USERIDHEADER
company_id_header optional Field name to identify Company (Account) from a request or response header. Type: String. TYK_PMP_PUMPS_MOESIF_META_COMPANYIDHEADER

Updated: