Monitor all API rate limits for a cloud service with a single global alert rule. When any API's usage or availability hits a threshold, alert contacts are notified to request a quota increase.
Use cases
High API call volumes can cause frequent throttling, impacting business stability. Instead of configuring individual alert rules per API, a global alert rule monitors all rate limits for a cloud service and enables proactive quota planning.
You can monitor global API usage and quotas through the console or API operations.
Billing
API rate limit alert rules consume your CloudMonitor notification quota. Billing varies by notification method:
Phone calls: No free quota is provided. You must enable pay-as-you-go or purchase a resource plan. For more information, see Pay-as-you-go and Resource plans.
SMS messages: A free quota of 1,000 messages per month is provided. If you exceed the free quota, you must enable pay-as-you-go or purchase a resource plan. For more information, see Free quotas, Pay-as-you-go, and Resource plans.
Email and alert callback: Both are free of charge.
Prerequisites
Create an alert contact and an alert contact group in the CloudMonitor console to receive alert notifications. For more information, see Create an alert contact or an alert contact group.
If you use a RAM user to manage quota alerts, the RAM user must have Quota Center administrator permissions (AliyunQuotasFullAccess) and permissions to create and delete quota alerts in CloudMonitor.
The following code provides a sample permission policy. For more information, see Create a custom permission policy and Manage permissions for a RAM user.
{ "Statement": [ { "Effect": "Allow", "Action": [ "cms:PutMetricRuleTargets", "cms:PutResourceMetricRules", "cms:DeleteMetricRules", "cms:DeleteMetricRuleTargets" ], "Resource": "*" } ], "Version": "1" }
Create a global alert by using the console
This example creates a global alert rule for all Compute Nest API rate limits, triggered at 80% usage. A Warning-level notification is sent by SMS and email to the alert contact group.
Use either the Quota Center or CloudMonitor console.
Quota Center console
-
In the Quota Center console, open the API Rate Limits page and select Compute Nest.
-
In the upper-right corner, click Global Alert Rules.
For parameter details, see Create an alert rule for a quota. Enter a Rule Name such as
quota-computenest-rulename-test. Set Metric to Usage Percentage (%) and the Warning threshold to >= 80% for one consecutive period, with SMS, email, and alert callback notifications. Set Silence Period to 5 Minutes, Effective Period to all day (00:00–23:59), and select an Alert Contact Group such as Cloud Account Alert Contact. Click Confirm. -
View the created rule in the alert rules list.
-
View the new alert rule.
In the left-side navigation pane, click Alert Rules. On the API Rate Limits tab, locate the rule. In the Actions column, click View, Modify, Delete, or Monitoring Details.
-
View monitoring details for APIs with usage data.
In the Actions column, click Monitoring Details. In the Quota Monitoring dialog box, select a target API (for example,
GetServiceTemplateParameterConstraints/2021-05-21), a region (for example,cn-hangzhou), and a metric (for example, Usage Percentage (%)), then specify a time range to view the usage percentage chart.
-
CloudMonitor console
-
In the Cloud Monitor Console, navigate to the Cloud Service Monitoring page. Select to open the API Rate Limits monitoring tab for Compute Nest.
-
In the upper-right corner, click Global Alert Rule. On the Global Alert Rule page, create an alert rule for the Compute Nest API rate limits.
For parameter details, see Create an alert rule for a quota.
Click + Create Alert Rule, enter a rule name such as
quota-computenest-rulename-test, select Usage Percentage as the metric, and set the Warning-level threshold to >=80%.In the notification settings, select Cloud Account Alert Contact for Alert Contact Group, configure the remaining parameters, and click OK.
-
View the created rule in the list.
The alert rule appears in the list with condition
Notify if UsagePercentage (Warn) >= 80 for 3 consecutive periods. The initial status is Insufficient Data.
Create a global alert by using an API
This example creates a global alert rule for all Compute Nest API rate limits, triggered at 80% usage. A Warning-level notification is sent by SMS and email to the alert contact group.
-
Verify that the target cloud service (Compute Nest) supports global alert rules for API rate limits.
Call ListProductQuotas and check the
UsageMetricresponse parameter. A non-emptyUsageMetricvalue indicates support for global alert rules.-
Request parameters: Set
ProductCodetocomputenestandQuotaCategorytoFlowControl. Keep the default values for the other parameters. -
Response parameters: The
UsageMetricobject contains API rate limit monitoring information from CloudMonitor. TheMetricNamespacevalue isacs_quotas_flowcontrol. Example response for an API rate limit:{ "QuotaDescription": "GetServiceTemplateParameterConstraints", "Consumable": false, "ProductCode": "computenest", "UsageMetric": { "MetricName": "Usage", "MetricDimensions": { "productCode": "computenest", "metricKey": "GetServiceTemplateParameterConstraints/2021-06-01", "regionId": "ap-southeast-1", "label": "none" }, "MetricNamespace": "acs_quotas_flowcontrol" }, "Dimensions": { "apiName": "GetServiceTemplateParameterConstraints", "apiVersion": "2021-06-01", "regionId": "ap-southeast-1" }, "GlobalQuota": false, "Period": { "PeriodValue": 1, "PeriodUnit": "second" }, "Adjustable": true, "QuotaActionCode": "f_4w8uhd", "QuotaName": "GetServiceTemplateParameterConstraints", "QuotaArn": "acs:quotas:ap-southeast-1:14133977********:quota/computenest/f_4w8uhd", "TotalQuota": 50, "QuotaCategory": "FlowControl" }NotemetricKeyis used to create an alert rule for a single, specified API rate limit.
-
-
Call DescribeMetricList to query monitoring data for the API rate limits. Use the usage trends to determine alert thresholds.
-
Request parameters: Set
Namespacetoacs_quotas_flowcontrol,MetricNametoUsagePercentage, andDimensionsto[{"productCode":"computenest"}]. Keep the default values for the other parameters.NoteThe
MetricNamein Quota Center includes:Quota(quota value),Usage(quota usage),UsagePercentage(quota usage percentage), andAvailablePercentage(available quota percentage). -
Return parameters: The
Valuefield inDatapointscan serve as a reference for the alert threshold. Example response:{ "RequestId": "2A7DB5BF-825C-51BB-AD91-D728857792F9", "Period": "60", "Datapoints": "[{\"timestamp\":1727337180000,\"productCode\":\"computenest\",\"metricKey\":\"GetServiceTemplateParameterConstraints/2021-05-21\",\"regionId\":\"cn-hangzhou\",\"label\":\"none\",\"userId\":\"14133977********\",\"Value\":2.0}]", "Code": "200", "Success": true }
-
-
Call PutResourceMetricRules to create a global alert rule for the API rate limits.
-
Request parameters: The following table lists the required parameters and example values.
Parameter
Description
Example
MetricName
The name of the metric. Valid values:
-
Quota: quota value
-
Usage: quota usage
-
UsagePercentage: usage percentage
-
AvailablePercentage: available percentage
NoteGlobal alert rules can only use
UsagePercentageandAvailablePercentage.UsagePercentage
Escalations.Warn.Threshold
The threshold for Warning-level alerts.
80
EffectiveInterval
The effective period of the alert rule.
00:00-23:59 +0800 dayofweek 1,2,3,4,5,6,7RuleId
The ID of the alert rule.
quota-computenest-ruleid-test
Escalations.Warn.ComparisonOperator
The comparison operator for the Warning-level threshold. Valid values:
-
GreaterThanOrEqualToThreshold: greater than or equal to
-
GreaterThanThreshold: greater than
-
LessThanOrEqualToThreshold: less than or equal to
-
LessThanThreshold: less than
-
NotEqualToThreshold: not equal to
-
GreaterThanYesterday: percent increase from the same time yesterday
-
LessThanYesterday: percent decrease from the same time yesterday
-
GreaterThanLastWeek: percent increase from the same time last week
-
LessThanLastWeek: percent decrease from the same time last week
-
GreaterThanLastPeriod: percent increase from the previous period
-
LessThanLastPeriod: percent decrease from the previous period
GreaterThanOrEqualToThreshold
Resources
The resource information.
NoteTo create an alert for a single API, specify the
Resourcesparameter as:[{"productCode":"computenest","metricKey":"GetServiceTemplateParameterConstraints/2021-06-01"}].[{"productCode":"computenest"}]
ContactGroups
The alert contact group.
CloudMonitor
Namespace
The data namespace of the cloud service.
acs_quotas_flowcontrol
RuleName
The name of the alert rule.
quota-computenest-rulename-test
Escalations.Warn.Times
The number of consecutive periods for which the condition must be met to trigger a Warning-level alert.
3
Escalations.Warn.Statistics
The statistical method for a Warning-level alert.
Value
-
-
A successful response indicates the rule is created.
{ "Message": "", "RequestId": "BE4CAC0F-A134-55BA-909B-FF62568FE884", "FailedListResult": { "Target": [] }, "Code": "200", "Success": true }
-
-
Call DescribeMetricRuleList to verify the alert rule by
RuleNameorRuleId.
Related documents
-
Create an alert for a single API rate limit: Create an alert rule for a quota
-
Request a quota increase after an alert: Create a quota increase application
-
View alert rule details: View the list and details of alert rules
-
View alert history: View quota alert history