Create a global quota alert to monitor all API rate limits for a cloud service. When any API's usage or availability reaches the threshold, alert contacts receive a notification to request a quota increase.
Use cases
Integrating many APIs for automated cloud resource management often leads to throttling from high-frequency calls, which impacts business stability. Configuring individual alerts for each API is impractical. A global alert rule monitors all APIs for a service at once.
You can monitor real-time API usage and quotas through the console or API calls.
Billing
API rate limit alerts use the CloudMonitor alerting feature and may consume your CloudMonitor service quotas. Billing for notification methods:
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 in the console
The following example creates a global quota alert for all Compute Nest API rate limits. The alert triggers when any API's usage reaches 80%, sending a Warn-level SMS and email notification to the specified alert contact group.
You can use either the Quota Center console or the CloudMonitor console.
Quota Center console
-
In the Quota Center console, go to the API Rate Limits page and select Compute Nest.
-
In the upper-right corner, click Global Alert Rules to create an alert rule for the API rate limits of Compute Nest.
Parameter details are in Create a quota alert. Set Rule Name to a custom name, such as
quota-computenest-rulename-test. Set Alert Scope to All Rate Limits. Set Alert Metric to Usage(%). For the Warn level, set the condition to trigger an alert if the usage is ≥ 80% for one consecutive period. For notification methods, select SMS, Email, and Alert Callback. In the notification section, set Mute For to 5 minutes and the Effective Period to 00:00-23:59 daily. For Alert Contact Group, select an alert contact group, such as Cloud Account Alert Contacts. In the alert callback section, enter a callback URL, such ashttp://alert.aliyun.com:8080/callback. Then, click OK. -
After creating the rule, view the global quota alert.
-
View the new alert rule.
In the left-side navigation pane, click Quota Alerts and select the API Rate Limits tab. The list shows the rule name, product, alert object, metric, condition, and notification channel. In the Actions column, you can View, Modify, or Delete a rule, or check its Monitoring Details.
-
View the monitoring details for each API with recorded usage.
In the Actions column, click Monitoring Details. In the Quota Monitoring dialog box, filter by API Name, Region, Metric, and Time Range to view usage trends for the API rate limit.
-
CloudMonitor console
-
On the Cloud Product Monitoring page in the CloudMonitor console, select to go to the API rate limit monitoring tab for Compute Nest.
-
In the upper-right corner, click Global Alert Rules. On the Global Alert Rules page, create an alert rule for the API rate limits of Compute Nest.
Parameter details are in Create a quota alert.
Click + Create Alert Rule. For Rule Name, enter a name such as
quota-computenest-rulename-test. For Alert Metric, select Usage. Under Threshold and Alert Level, set the Warn-level threshold to >= 80%.In the notification section, set Mute For to 5 minutes and the Effective Period from 00:00 to 23:59 for all days of the week. Select an Alert Contact Group, such as Cloud Account Alert Contact Group, and click OK to create the alert rule.
-
After creating the rule, view the global quota alert.
On the Global Alert Rules page in CloudMonitor, filter by Quota Type and Rule Name to find the rule. The table shows the rule status, name/ID, quota type, alert condition (for example,
Notify if UsagePercentage (Warn) >= 80 for 3 consecutive periods), and alert contact group.
Create a global alert via API
The following example creates a global quota alert for all Compute Nest API rate limits. The alert triggers when any API's usage reaches 80%, sending a Warn-level SMS and email notification to the specified alert contact group.
-
Check whether the API rate limits of the target cloud service (in this case, Compute Nest) support global quota alerts.
Call the Quota Center API ListProductQuotas to check the
UsageMetricresponse parameter. IfUsageMetricis not empty, Compute Nest supports global quota alerts for API rate limits.-
Request parameters: Set
ProductCodetocomputenestandQuotaCategorytoFlowControl. Leave the other parameters at their default values. -
Return parameters: The
UsageMetricparameter contains the monitoring information about the API rate limit from CloudMonitor. The value ofMetricNamespaceisacs_quotas_flowcontrol. The information returned for each API rate limit is as follows:{ "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" }NoteUse the
metricKeyparameter to create an individual quota alert for a specific API rate limit.
-
-
Call the CloudMonitor API DescribeMetricList to query monitoring data for API rate limits. Use the trends to configure alert thresholds.
-
Request parameters: Set
Namespacetoacs_quotas_flowcontrol,MetricNametoUsagePercentage, andDimensionsto[{"productCode":"computenest"}]. Leave the other parameters at their default values.NoteThe
MetricNamein Quota Center includes:Quota(quota value),Usage(quota usage),UsagePercentage(usage percentage), andAvailablePercentage(available quota percentage). -
Return parameters: In
Datapoints, you can obtain the value ofValueto use as a reference for the alert threshold. The returned information is as follows:{ "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 the CloudMonitor API PutResourceMetricRules to create a global quota alert rule for API rate limits.
-
Request parameters: Required request parameters and examples:
Parameter
Description
Example
MetricName
The metric name. Valid values:
-
Quota: Quota value
-
Usage: Quota usage
-
UsagePercentage: Usage percentage
-
AvailablePercentage: Available percentage
NoteGlobal quota alerts support only
UsagePercentageandAvailablePercentage.UsagePercentage
Escalations.Warn.Threshold
The threshold for a Warn-level alert.
80
EffectiveInterval
The effective period for 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 Warn-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: higher than the same time yesterday.
-
LessThanYesterday: lower than the same time yesterday.
-
GreaterThanLastWeek: higher than the same time last week.
-
LessThanLastWeek: lower than the same time last week.
-
GreaterThanLastPeriod: higher than the previous period.
-
LessThanLastPeriod: lower than the previous period.
GreaterThanOrEqualToThreshold
Resources
The resource information.
NoteTo create an individual quota alert for a specific API, use this Resources format:
[{"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 retries for a Warn-level alert.
3
Escalations.Warn.Statistics
The statistical method for a Warn-level alert.
Value
-
-
A successful response:
{ "Message": "", "RequestId": "BE4CAC0F-A134-55BA-909B-FF62568FE884", "FailedListResult": { "Target": [] }, "Code": "200", "Success": true }
-
-
Call the CloudMonitor API DescribeMetricRuleList to verify the alert rule by
RuleNameorRuleId.
Related documents
-
To create a quota alert for a specific API rate limit, follow Create a quota alert.
-
After receiving a quota alert, request a quota increase. Submit an application to increase a quota.
-
After creating a quota alert, view its details. View a quota alert list and the details of a quota alert.
-
After creating a quota alert, view the alert history. View the history of quota alerts.