All Products
Search
Document Center

API Gateway:Configure alerting for APIs

Last Updated:Jun 21, 2026

You can use CloudMonitor to configure alerts for APIs published in API Gateway. This helps you track the operational status of your API services and ensure their stability.

1. Associate resources

The monitoring and alerting feature of API Gateway can meet various business requirements. API Gateway supports the following monitoring metrics:

  • HttpStatusCode

  • API response time

  • Total API requests

  • inbound traffic

  • outbound traffic

You can use one of the following methods to create an alert rule and associate the alert rule with one or more APIs:

  • Manually associate one or more APIs. This method is suitable for applying the same alert rule to specific APIs. The alert rule is not affected if the API configuration is modified.

  • Associate an API group. This applies the same alert rule to all APIs within the group to monitor their call status. If you add, delete, or modify APIs in the group, the alert rule is automatically synchronized.

  • Associate all resources. This applies the rule to all APIs in API Gateway under your account. This method is suitable for scenarios where you manage a small number of APIs.

Note

If you use the first or second method, you can select a specific environment in which you want to create an alert rule to configure monitoring and alerting for APIs. For example, you can select a production (RELEASE), staging (PRE), or test (TEST) environment.

2. Configure alert levels and methods

CloudMonitor can trigger Critical, Warning, or Info alerts, depending on the threshold range. Each level can send notifications through different channels. For details on alert notifications, see Overview.

  • Critical: Phone call + SMS message + email + DingTalk chatbot (paid feature).

  • Warning: SMS message + email + DingTalk chatbot.

  • Info: Email + DingTalk chatbot.

Note

For example, you can set an alert rule to trigger a notification if the count of 2XX status codes exceeds 200 each minute for five consecutive minutes.

3. Associate an alert rule with one or more APIs

For details on configuring alert templates, alert rules, notification contacts, and alert notifications, see Overview.

  1. Log on to the API Gateway console and select a region. In the left-side navigation pane, choose API Management > API List, and find the API to which you want to add an alert rule.

  2. In the API List, click the API name to open its details page. In the left-side navigation pane, click Monitoring. Then, click Alert in the upper-right corner to open the CloudMonitor console.

  3. On the Alert Rules page, click Create Alert Rule. On the Create Alert Rule page, set Product to API Gateway and Resource Range to Instance. Click Add Instance below. In the Add Instance dialog box, select the APIs you want to add.

4. Associate an alert rule with an API group

  1. To apply the same alert rule to all APIs in an API group, go to the group's details page and click Enable CloudMonitor in the upper-right corner.

  2. When you configure CloudMonitor for an API group for the first time, a dialog box prompts you to create an AliyunServiceRoleForApiGatewayMonitoring service-linked role.

  3. After you click OK, a message indicates that CloudMonitor is enabled and provides the name of the corresponding application group in CloudMonitor. With your authorization, API Gateway creates this application group to mirror the current API group. The name follows the format APIGATEWAY_${region}_${groupId}, where region is the region of the API group and groupId is its ID.

  4. After CloudMonitor is enabled, click Go to CloudMonitor to Configure on the group details page to directly configure alert rules for the current application group.

5. Associate an alert rule with all APIs

The procedure is the same as in Create an alert rule for one or more APIs, except you must set the Resource Range to "All Resources". Once set, the same alert rule applies to all APIs across all regions in API Gateway under your account. With this method, you cannot select specific APIs.

6. Alert rules supported by API Gateway

You can configure alerts based on five metrics provided by API Gateway: HttpStatusCode, API response time, Total API requests, inbound traffic, and outbound traffic.

  • Response time of an API: the response time of a backend service.

  • Total number of requests for an API: the total number of requests that are received by API Gateway for a specific API from clients within a specific period.

  • Inbound traffic: the traffic of requests that are received by API Gateway from clients within a specific period.

  • Outbound traffic: the traffic of requests that are sent to the backend services from API Gateway within a specific period.

  • HTTP status code: the status codes that are returned by API Gateway. The following HTTP status codes are supported:

-HTTP 2XX status code: The API request is received. Note: A received request does not indicate that the operation intended by the request is successful.

-HTTP 4XX status code: An error occurs on the client, such as a parameter error.

-Code5XX: Indicates a server-side error. API developers should typically monitor these errors closely.

7. Usage notes

  • You can configure an alert rule based on the environment in which your API is published. If an alert rule configured for an API that is published in a VPC does not take effect, we recommend that you perform the following operations: Log on to the API Gateway console, find the API, and then click the API name to go to the API details page. In the left-side navigation tree, click Monitoring. On the Monitoring Data page, check whether you can query the monitoring data of the API by environment. If you cannot query the monitoring data by environment, submit a ticket to update the version of your API Gateway instance.