Login 24/7 Support Community

Moesif Setup

This is a step by step guide to setting up Moesif API Analytics to receive logs from the Tyk Pump.

We also have a blog post which highlights how Tyk and Moesif work together.

The assumptions are that you have Docker installed and Tyk Pro On-premises already running. See the Tyk Pump Configuration for more details.

Overview

With the Moesif Tyk plugin, your API logs are sent to Moesif to provide analytics on API traffic along with your API payloads like JSON and XML. Moesif also collects information such as the authenticated user (AliasId or OAuthId) so you’re able to drill into activation funnels and track metrics like active users. An overview on how Moesif and Tyk works together is available here.

1. Get a Moesif Application Id

Go to www.moesif.com and sign up for a free account. Application Ids are write-only API keys specific to an application in Moesif such as “Development” or “Production”. You can always create more applications in Moesif.

2. Add the Moesif backend to pump.conf

Edit your pump’s pump.conf and Moesif as an analytics backend along with your Moesif Application Id you obtained in the last step.

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

3. Ensure analytics is enabled

If you want to log HTTP headers and body, ensure detailed analytics recording is enabled in your tyk.conf file.

{
    "enable_analytics" : true,
    "analytics_config": {
    "enable_detailed_recording": true
    }
}

4. Restart Tyk Pump to pickup the Moesif config

Once your config changes are done, you need to restart your Tyk Pump and Tyk Gateway instances (if modified tyk.conf). If you are running Tyk Pump in Docker:

$ docker restart tyk-pump

5. PROFIT!

You can now make a few API calls and verify they show up in Moesif.

$ curl localhost:8080

Step5

The Moesif Tyk integration automatically maps a Tyk Token Alias to a user id in Moesif. With a Moesif SDK, you can store additional customer demographics to break down API usage by customer email, company industry, and more.

Configuration options

The Tyk Pump for Moesif has a few configuration options that can be set in your pump.conf:

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. Default maps to the token alias
company_id_header optional Field name to identify Company (Account) from a request or response header. Type: String.