IBM API Management provides a range of built-in analytics to help you understand and manage the system, your APIs and your consumers. Operations can keep an eye on server and cluster health in the Cloud Console. API providers can manage their APIs by understanding the usage of their APIs. Application developers can understand how their applications are using the APIs they signed up for.


1

In addition to these out of the box analytics, IBM API Management v3 offers a search view, which allows you to create your own custom queries to gain a deeper understanding of your APIs.


2

The search page allows you to see an overview of the number of calls and of response times for all the calls in the search results. You can drill down into each API call and see the details of parameters, headers and request/response bodies.


3

Several common filters are provided in the UI. These include filtering by Environment, Plan, API, Resource, Application Developer, and Application. For more advanced searching, you can enter a query in the search field. To get you started, there are a number of example queries below. Once you have run a query, you can bookmark it in your browser, or click the “Share” button to copy the URL.

Calls made by Application Developers

In order to understand the usage of your APIs by your Developer Organizations, you can query how many calls they have made.  There is a filter provided on the search page.  Once you have selected a Developer Organization you can also filter down to specific Applications.

Finding Application Developers to upsell to Plans with higher rate limits

If you want to know which Application Developers might be interested in paying for a Plan with higher rate limits, you can search either for those who are nearing their rate limits, or for those who have already exceeded them.

Query (nearing limit): responseHttpHeaders.X-RateLimit-Remaining:[0 TO 10]

Query (over limit): statusCode:429

Find API calls that resulted in errors

In order to understand if there are any issues with your APIs, you want to know how many API calls resulted in an error in the last 2 days.

Query: NOT statusCode:2* AND datetime:[2014-06-15 TO 2014-06-16]

Discovering what devices are making use of your APIs

To discover what devices are calling your APIs, you can search on the user agent string.  For example, you can find out how many calls were made from Android or iOS devices.

Query (Android): requestHttpHeaders.User-Agent:Android

Query (iOS): requestHttpHeaders.User-Agent:iPhone OR requestHttpHeaders.User-Agent:iPad OR requestHttpHeaders.User-Agent:iPod

Finding API calls that did not return quickly enough

If you have an Service Level Agreement (SLA) with a consumer which states that all your API calls should respond within a certain time (e.g. 1 second). You can check for any calls taking longer than this, in order to show whether you are meeting the SLA.

Query: timeToServeRequest:[1000 TO *] AND apiUser:<consumerOrg>

Finding API calls from particular IP addresses

If you suspect there is a large amount of API calls coming from one source, you can find out how many calls are coming from particular sources.

Query: requestHttpHeaders.X-Client-IP:9.20.*

.

Analyzing your business data

So far we have seen searching for API calls based on metadata. We can also search using the actual data sent and received in the API calls. This will be specific to your business and APIs. To provide a couple of examples, we will consider the kind of data that a retail company might have in it’s APIs.

How many of item X have you sold

You want to know how many of a new item has been sold in the last week.

Assuming an API such as:  POST /shop/checkout

with request body: {“productId”:<id>}

First, select the relevant resource in the UI and then use:

Query: requestBody.productId:<productId>

How many times has a type of item been viewed on your website/app

You want to know how many views of red dresses there have been.

Assuming an API such as:  GET /catalog/item/{id}

with response body: {“productId”:<id>, “color”:<color>, “type”:<type>, “price”:<price>}

Select the relevant API resource in the UI and then use:

Query: responseBody.color:red AND responseBody.type:dress

You could also combine this with a metadata query to find out how many views there have been from a mobile device:

Query: responseBody.color:red AND responseBody.type:dress AND requestHttpHeaders.User-Agent:*Mobile*

Querying XML Bodies

As well as being able to query JSON request and response bodies, you can also query XML bodies.  For a response like:

<result>

<status>0</status>

</result>

You can use:

Query: responseBody.result.status.$:0

.

As we have seen, the search facility in IBM API Management provides you with a way to dig into your analytics data and gain insights into your APIs and business.  I hope that you find these queries useful and you can make use of them with your own APIs.  If you’re interested in the IBM API Management product, please visit our product page.

2 comments on"Digging Deeper with Analytics in IBM API Management"

  1. NateTheRobot June 22, 2014

    Hi Simon,

    This is a great article. Do you know if there is a page lists all the system-defined fields that we can include in the queries? I poke around the APIM v3 info center but not really a page lists them all.

    • Simon Burns June 25, 2014

      I don’t think there is a page which lists all the fields, so here you go:

      – datetime
      – requestMethod
      – uriPath
      – queryString
      – statusCode
      – timeToServeRequest
      – apiUser
      – responseHttpHeaders
      – requestHttpHeaders
      – requestBody
      – responseBody
      – bytesReceived
      – bytesSent

      Filters for environment, plan, API and resource are available on the search page.

Join The Discussion

Your email address will not be published. Required fields are marked *