Activity by endpoint

Last updated: 4 minutes read.

To get a tabular view of how your API traffic is performing at the endpoint level, you can select the Activity by Endpoint option in the navigation and see a tabular view of your API endpoints. This table will list your API endpoints by their traffic volume and you’ll be able to see when they were last accessed:

Activity by endpoint

Controlling which endpoints appear in the analytics data

The aggregate pumps have an option to track_all_paths which will ensure that all analytics records generated by the Tyk Gateway will be included in the aggregated statistics on the Endpoint Popularity screen. Set this to true to capture all endpoints in the aggregated data and subsequently on the Dashboard page.

You can alternatively select only a subset of the endpoints to include in the aggregated data by setting track_all_paths to false and identifying specific endpoints to be “tracked”. These are identified by the TrackPath flag being set to true in the record. In this configuration, the Pump will only include transaction records from “tracked” endpoints in the aggregated data.

Tyk Gateway will set TrackPath to true in transaction records generated for endpoints that have the track endpoint middleware enabled.

Note

The track endpoint middleware only affects the inclusion of endpoints in the per-endpoint aggregates, it does not have any impact on other aggregated data nor the per-request data.

Selecting Tyk OAS APIs endpoints to be tracked

The design of the Tyk OAS API Definition takes advantage of the operationId defined in the OpenAPI Document that declares both the path and method for which the middleware should be added. The path can contain wildcards in the form of any string bracketed by curly braces, for example {user_id}. These wildcards are so they are human readable and do not translate to variable names. Under the hood, a wildcard translates to the “match everything” regex of: (.*).

The track endpoint middleware (trackEndpoint) can be added to the operations section of the Tyk OAS Extension (x-tyk-api-gateway) in your Tyk OAS API Definition for the appropriate operationId (as configured in the paths section of your OpenAPI Document).

The trackEndpoint object has the following configuration:

  • enabled: enable the middleware for the endpoint

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
    "components": {},
    "info": {
        "title": "example-track-endpoint",
        "version": "1.0.0"
    },
    "openapi": "3.0.3",
    "paths": {
        "/anything": {
            "get": {
                "operationId": "anythingget",
                "responses": {
                    "200": {
                        "description": ""
                    }
                }
            }
        }
    },
    "x-tyk-api-gateway": {
        "info": {
            "name": "example-track-endpoint",
            "state": {
                "active": true
            }
        },
        "upstream": {
            "url": "http://httpbin.org/"
        },
        "server": {
            "listenPath": {
                "value": "/example-track-endpoint/",
                "strip": true
            }
        },
        "middleware": {
            "operations": {
                "anythingget": {
                    "trackEndpoint": {
                        "enabled": true
                    }               
                }
            }
        }
    }
}

In this example the track endpoint middleware has been configured for requests to the GET /anything endpoint. These requests will appear in the Endpoint Popularity analytics screen, located within the API Usage section of Tyk Dashboard.

The configuration above is a complete and valid Tyk OAS API Definition that you can import into Tyk to try out the track endpoint middleware.

Configuring the middleware in the API Designer

Adding the track endpoint middleware to your API endpoints is easy when using the API Designer in the Tyk Dashboard, simply follow these steps:

Step 1: Add an endpoint

From the API Designer add an endpoint that matches the path and method to which you want to apply the middleware.

Tyk OAS API Designer showing no endpoints created

Adding an endpoint to an API using the Tyk OAS API Designer

Tyk OAS API Designer showing no middleware enabled on endpoint

Step 2: Select the Track Endpoint middleware

Select ADD MIDDLEWARE and choose the Track Endpoint middleware from the Add Middleware screen.

Adding the Track Endpoint middleware

Step 3: Save the API

Select SAVE API to apply the changes to your API.

Selecting Tyk Classic API endpoints to be tracked

If you are working with Tyk Classic APIs then you must add a new track_endpoints object to the extended_paths section of your API definition.

The track_endpoints object has the following configuration:

  • path: the endpoint path
  • method: the endpoint HTTP method

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "extended_paths": {
        "track_endpoints": [
            {
                "disabled": false,
                "path": "/anything",
                "method": "GET",
            }
        ]
    }
}

In this example the track endpoint middleware has been configured for HTTP GET requests to the /anything endpoint. These requests will appear in the Endpoint Popularity analytics screen, located within the API Usage section of Tyk Dashboard.

Configuring the middleware in the API Designer

You can use the API Designer in the Tyk Dashboard to configure the track endpoint middleware for your Tyk Classic API by following these steps.

Step 1: Add an endpoint for the path and select the plugin

From the Endpoint Designer add an endpoint that matches the path for which you want to allow access. Select the Track endpoint plugin.

Select the middleware

Step 2: Save the API

Use the save or create buttons to save the changes and activate the middleware for the selected endpoint.