Creates or modifies an alert rule.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
arms:CreateAlertRules | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
AlertId | long | No | The ID of the alert rule.
| 546xxx |
AlertName | string | Yes | The name of the alert rule. | Alert Rule Demo |
RegionId | string | Yes | The region ID. | cn-hangzhou |
AlertType | string | Yes | The type of the alert rule. Valid values:
| APPLICATION_MONITORING_ALERT_RULE |
AlertStatus | string | No | The status of the alert rule. Valid values:
| RUNNING |
NotifyStrategy | string | No | The notification policy.
| 569xxx |
Pids | string | No | The process ID (PID) that is associated with the Application Monitoring or Browser Monitoring alert rule. | ["b590lhguqs@40d8deedfa9******"] |
AutoAddNewApplication | boolean | No | Specifies whether to apply the alert rule to new applications that are created in Application Monitoring or Browser Monitoring. Valid values:
| false |
MetricsType | string | No | The metric type of the Application Monitoring or Browser Monitoring alert rule. For more information, see the following table. | jvm |
Filters | string | No | The filter conditions of the Application Monitoring or Browser Monitoring alert rule. Format:
Valid values of FilterOpt:
| {"DimFilters": [ { "FilterOpt": "ALL", "FilterValues": [], "FilterKey": "rootIp" } ] } |
AlertRuleContent | string | No | The content of the Application Monitoring or Browser Monitoring alert rule. The following code provides an example of the AlertRuleContent parameter. For more information about the meaning of each field, see the supplementary description.
Note
The filter conditions specified by the AlertRuleItems.MetricKey field depends on the value of the MetricsType parameter. For more information about the types of metrics supported by Application Monitoring and Browser Monitoring and the alert rule fields corresponding to each metric, see the supplementary description.
| { "Condition": "OR", "AlertRuleItems": [ { "Operator": "CURRENT_LTE", "MetricKey": "appstat.jvm.threadcount", "Value": 1000, "Aggregate": "AVG", "N": 1 } ] } |
AlertCheckType | string | No | The alert check type of the Prometheus alert rule. Valid values:
| STATIC |
ClusterId | string | No | The ID of the monitored cluster. | ceba9b9ea5b924dd0b6726d2de6****** |
AlertGroup | long | No | The alert contact group ID of the Prometheus alert rule. Valid values:
| -1 |
PromQL | string | No | The PromQL statement of the Prometheus alert rule. | node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100 |
Duration | long | No | The duration of the Prometheus alert rule, in minutes, in the range of [0,1440]. | 1 |
Level | string | No | The severity level of the Prometheus alert rule.
| P2 |
Message | string | No | The alert message of the Prometheus alert rule. | Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} Memory usage exceeds 80%. Current value: {{ printf \\\\\"%.2f\\\\\" $value }}% |
Labels | string | No | The tags of the Prometheus alert rule. | [ { "Value": "cms_polardb", "Name": "_aliyun_cloud_product" } ] |
Annotations | string | No | The annotations of the Prometheus alert rule. | \[ { "Value": "PolarDB slow queries", "Name": "\_aliyun_display_name" } |
MetricsKey | string | No | The alert metrics. If you set the AlertCheckType parameter to STATIC when you create a Prometheus alert rule, you must specify the MetricsKey parameter. Note
Alert metrics vary depending on the value of the AlertGroup parameter. For more information about the correspondence between AlertGroup and MetricsKey, see the supplementary description.
| pop.status.error |
Tags | array<object> | No | The list of tags. | |
object | No | |||
Key | string | No | The tag key. | owner |
Value | string | No | The tag value. | John |
MarkTags | array<object> | No | Application Tags. Used for application monitoring alert rules, to filter applications associated with alert rules. | |
object | No | Associated Application Tags. | ||
Key | string | No | The Tag Key. | service |
Value | string | No | The Tag Value. | proudct |
DataConfig | string | No | Data Configuration. The dataRevision field specifies the data repair method when there is no data for the metric.
| { "dataRevision": 2 } |
Notice | string | No | The effective time and notification time. This parameter is used to be compatible with the old version of the rule. | - |
AlertPiplines | string | No | The configuration of the alert sending channel. This parameter is used to be compatible with the old version of the rule. | - |
NotifyMode | string | No | The notification mode. You can specify the normal mode or simple mode.
| NORMAL_MODE |
Product | string | No | The product code. If you specify this parameter when you create a Prometheus alert rule, the backend checks whether the product exists. | clickhouse |
AutoAddTargetConfig | string | No | The configurations that are automatically appended to monitor the application based on the specified alert rule.
| {\"autoAddMatchType\":\"REGULAR\",\"autoAddMatchExp\":\".*cbw.*\"} |
AlertRuleContent
{
"Condition": "OR",
"AlertRuleItems": [
{ "Operator": "CURRENT_LTE",
"MetricKey": "appstat.jvm.threadcount",
"Value": 1000,
"Aggregate": "AVG",
"N": 10,
"Tolerability": 169
}
]
}
- Condition: Trigger logic between multiple alarm conditions.
- OR: Satisfy any of the following conditions.
- AND: Satisfy the following conditions at the same time.
- Operator: Judgment condition of the alarm condition.
- CURRENT _ GTE: Greater than or equal to
- CURRENT _ LTE: Less than or equal to
- PREVIOUS _ UP: Month-on-month increase percentage
- PREVIOUS _ DOWN: Month-on-month decrease percentage
- HOH _ UP: Year-on-year increase percentage compared with the previous hour
- HOH _ DOWN: Year-on-year decrease percentage compared with the previous hour
- DOD _ UP: Year-on-year increase percentage compared with yesterday
- DOD _ DOWN: Year-on-year decrease percentage compared with yesterday
- INTERVAL _ EXCEED: Interval detection. Note: Interval detection does not support multi-condition triggering.
- Metric Key: The indicator of the specific alarm condition. Different Metrics Types have different corresponding indicators. Please refer to the following description for the corresponding relationship.
- Value: Alarm condition threshold.
- Aggregate: Alarm condition aggregation method.
- AVG: Average
- SUM: Sum
- MAX: Maximum value
- MIN: Minimum value
- CONTINUOUS: Continuous
- AVG _ WEIGHTED: Weighted average of error rate
- N: The last N minutes.
- Tolerability: Indicates the interval tolerance, with a value between 1 and 200.
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "337B8F7E-0A64-5768-9225-E9B3CF******",
"AlertRule": {
"AlertId": 5510445,
"AlertName": "arms-test",
"UserId": "1131971649******",
"RegionId": "cn-hangzhou",
"AlertType": "APPLICATION_MONITORING_ALERT_RULE",
"AlertStatus": "RUNNING",
"CreatedTime": 1641438611000,
"UpdatedTime": 1641438611000,
"Extend": "{\\\\\"alarmContext\\\\\":\\\\\"{\\\\\\\\\\\"content\\\\\\\\\\\":\\\\\\\\Alert name: $Alert name\\\\\\\\\\\\nFilter condition: $Filter condition\\\\\\\\\\\\nAlert time: $Alert time\\\\\\\\\\\\nAlert content: $Alert content\\\\\\\\\\\\nNote: The alert persists before you receive an email that reminds you to clear the alert. You will be reminded of the alert again 24 hours later. \\\\\\\\\\\",\\\\\\\\\\\"subTitle\\\\\\\\\\\":\\\\\\\\\\\"\\\\\\\\\\\"}\\\\\",\\\\\"alertWays\\\\\":\\\\\"\\[0,1]\\\\\",\\\\\"contactGroupIds\\\\\":\\\\\"381,5075\\\\\",\\\\\"notice\\\\\":\\\\\"{\\\\\\\\\\\"endTime\\\\\\\\\\\":1480607940000,\\\\\\\\\\\"noticeEndTime\\\\\\\\\\\":1480607940000,\\\\\\\\\\\"noticeStartTime\\\\\\\\\\\":1480521600000,\\\\\\\\\\\"startTime\\\\\\\\\\\":1480521600000}\\\\\"}\n",
"NotifyStrategy": "ALERT_MANAGER",
"Pids": [
"b590lhguqs@40d8deedfa9******"
],
"AutoAddNewApplication": false,
"MetricsType": "JVM",
"AlertRuleContent": {
"Condition": "\"|\"",
"AlertRuleItems": [
{
"N": 1,
"MetricKey": "appstat.jvm.non_heap_used\n",
"Aggregate": "AVG",
"Operator": "CURRENT_GTE",
"Value": "1"
}
]
},
"Filters": {
"DimFilters": [
{
"FilterKey": "rootIp",
"FilterOpt": "ALL",
"FilterValues": [
"[]"
]
}
],
"CustomSLSFilters": [
{
"Key": "username",
"Opt": "=",
"Value": "test",
"T": "null",
"Show": false
}
],
"CustomSLSGroupByDimensions": [
"[\"page\"]"
],
"CustomSLSWheres": [
"[\"t like '%api%'\"]"
]
},
"AlertCheckType": "STATIC",
"ClusterId": "ceba9b9ea5b924dd0b6726d2de6******",
"AlertGroup": -1,
"PromQL": "node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100",
"Duration": "1",
"Level": "P2",
"Message": "Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} Memory usage exceeds 80%. Current value: {{ printf \\\\\\\\\\\"%.2f\\\\\\\\\\\" $value }}%\n",
"Labels": [
{
"Name": "123",
"Value": "abc"
}
],
"Annotations": [
{
"Name": "123",
"Value": "abc"
}
],
"Tags": [
{
"Key": "owner",
"Value": "John"
}
],
"NotifyMode": "NORMAL_MODE"
}
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-05-07 | The request parameters of the API has changed | View Change Details |
2024-04-29 | The request parameters of the API has changed | View Change Details |
2023-12-18 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-10-20 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-10-17 | The response structure of the API has changed | View Change Details |
2023-10-16 | The request parameters of the API has changed | View Change Details |
2023-10-11 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-09-14 | The request parameters of the API has changed | View Change Details |
2023-08-24 | The request parameters of the API has changed | View Change Details |
2023-05-11 | The request parameters of the API has changed. The response structure of the API has changed | View Change Details |