API Transaction Logging

Why API Transaction Logging?

You can enable transaction logging for API to record and view the activities of your API. This record keeps a track of when an event occurred, why it occurred and what was impacted. The audit logs provide a detailed record of various auditable events of an API such as user login and logout details and the user responsible for it. By logging the transactions of the API, you can learn more about API activities, which may be useful for troubleshooting if something goes wrong.

API Gateway has the capability to log transactions and capture data of various auditable events of APIs. By default, API Gateway does not log the transactions. You must enable transaction logging so that the log data for the API to view the analytics of the API and detect anomalies.
This section describes how to activate the online_petstore API in API Gateway, enable transaction logging of the API, and view the logs and analytics at the API level.

Before you begin

Ensure the API you are working with is created and enforced with the required policies.

To enable and verify API Transcation Logging

  1. Ensure online_petstore API is activated.

    Before enabling audit API, you must first activate it so that the users can access the gateway localhost and use the API.
    If the API is not in active state, perform the following steps:

    a. Log onto your API Gateway instance.
    b. Click APIs on the title navigation bar.
    c. Select online_petsore API from the list of APIs and click icon to activate the API.

  2. Enable transaction logging API

    a. Click online_petstore > Policies.

    b. Expand the traffic monitoring tab on the left pane.
    c. Click Log Invocation.

    d. Select the required Log Invocation policy properties in the right pane and select API Gateway as the destination.

    e. Click Save.

    Note
    If you want to apply the transaction logging changes to all the APIs, you can use a Global policy.
  3. View the analytics data

    a. Go to Postman.
    b. Set the request method to GET and type the URL: http://host/port/gateway/online_petsore/1.0.6.
    c. Click the Send button to invoke the endpoint.
    d. On the API Gateway instance, click APIs on the title navigation bar.
    e. Select online_petstore API > API Analytics.

    This displays the API-specific transaction data.

    Transaction logging data with Payload properties:

    Transaction logging data without Payload properties:

    This chart specifies the number of events generated at a specific time. The analytics data remains the same regardless of whether the payload log invocation properties are selected or not.

    The headers and the payload log data are saved when the payload properties are enabled. In this case, the size of the data increses drastically. If the payload properties are disabled, then only the headers are saved. The size of the data is minimal.

    You can sort the data by selecting the required options in the filter.