How do I use Amazon CloudWatch Metrics Insights to identify the most used APIs?

3 minute read
0

I want to use Amazon CloudWatch Metrics Insights to identify the most used APIs.

Short description

CloudWatch Metrics Insights can be used to query your metrics at scale. You can use CloudWatch Metrics Insights to identify the most used APIs in your account in real time.

Resolution

Identify the most used AWS APIs in your account

Complete the following steps:

  1. Sign in to the CloudWatch console.
  2. In the navigation pane, choose Metrics, and then All metrics.
  3. Choose the Multi source query tab.
  4. Choose Add query and select AWS API usage examples. Then, choose Top 20 AWS APIs by the number of calls in your account.
  5. View the populated details of the query under Builder View on the query tab. To see the query in SQL structure, switch to Editor view.
    Example query in Editor view:
    SELECT COUNT(CallCount)
    FROM SCHEMA("AWS/Usage", Class, Resource, Service, Type)
    WHERE Type = 'API'
    GROUP BY Service, Resource
    ORDER BY COUNT() DESC
    LIMIT 20

Note: The default sample query selected from the menu shows 20 APIs. To change the Limit value, complete the following steps.

  1. (Optional) From Builder View on the query tab, select the X mark located next to 20 in the Limit section and choose a new limit value. When complete, select Graph query to update the query and graph.
  2. (Optional) From Editor View on the query tab, update the Limit value. Then, select Run to update the query and graph.

Note: When you change the Limit keyword value, the query indicates the most used APIs in your account for your specific AWS Region.

Identify the most used CloudWatch APIs by call counts

Complete the following steps:

  1. Sign in to the CloudWatch console.
  2. In the navigation pane, choose Metrics, and then All metrics.
  3. Choose the Multi source query tab.
  4. Choose Add query and select AWS API usage examples. Then, choose CloudWatch APIs sorted by calls.
    Example query:
    SELECT COUNT(CallCount)
    FROM SCHEMA("AWS/Usage", Class, Resource, Service, Type)
    WHERE Type = 'API' AND Service = 'CloudWatch'
    GROUP BY Resource
    ORDER BY COUNT() DESC

Note: To modify the number of APIs, use the Limit keyword on the Metrics Insights query. To query results for a specific service, use the Service attribute.

Related information

AWS API usage examples

CloudWatch usage examples

Metrics Insights limits

AWS OFFICIAL
AWS OFFICIALUpdated 2 months ago