Log API transactions

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 might be useful for troubleshooting if something goes wrong.

Before you begin

Make sure that the API you are working with is created and enforced with the necessary policies.

About this task

webMethods API Gateway can log transactions and capture data of various auditable events of APIs. By default, webMethods API Gateway does not log the transactions. Enable transaction logging so that the log data for the API to view the analytics of the API and detect anomalies. The following section describes how to activate the online_petstore API in webMethods API Gateway, enable transaction logging of the API, and view the logs and analytics at the API level.

Procedure

  1. Make sure the online_petstore API is activated.

    Before you enable the 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 an active state, perform the following steps.

    1. Log on to your webMethods API Gateway instance.
    2. Open the menu options and selectAPIs.
    3. Select online_petsore API from the list of APIs and set Activate to on to activate the API.
  2. Enable transaction logging API
    1. Click online_petstore > Policies.
    2. Expand the traffic monitoring tab.
    3. Click Log Invocation.
    4. Select the necessary Log Invocation policy properties in the right window and select webMethods API Gateway as the destination.
    5. Click Save. If you want to apply the transaction logging changes to all the APIs, you can use a Global policy.
  3. View the analytics data
    1. Go to the Postman.
    2. Set the request method to GET and type the URL- http://host:port/gateway/online_petstore/1.0.6
    3. Click Send to call the endpoint.
    4. On the webMethods API Gateway instance, Open the menu options and click APIs.
    5. Select online_petstore API > API Analytics. This function displays the API-specific transaction data.

      The chart specifies the number of events generated at a specific time. The analytics data remains the same regardless of whether the properties of payload log invocation 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 increases 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 necessary options in the filter.