Creates or updates an alert rule for Application Monitoring, Browser Monitoring, or Prometheus Service.
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| Action | String | Yes | CreateOrUpdateAlertRule |
The operation that you want to perform. Set the value to CreateOrUpdateAlertRule. |
| AlertId | Long | No | 123 |
The ID of the alert rule.
|
| AlertName | String | Yes | test-alert |
The name of the alert rule. |
| RegionId | String | Yes | cn-hangzhou |
The ID of the region. |
| AlertType | String | Yes | APPLICATION_MONITORING_ALERT_RULE |
The type of the alert rule. Valid values:
|
| AlertStatus | String | No | RUNNING |
The status of the alert rule.
|
| NotifyStrategy | String | No | null |
The notification policy.
|
| Pids | String | No | ["b590lhguqs@40d8deedfa9******"] |
The process ID (PID) that is associated with the Application Monitoring or Browser Monitoring alert rule. |
| AutoAddNewApplication | Boolean | No | false |
Specifies whether to apply the alert rule to new applications that are created in Application Monitoring or Browser Monitoring.
|
| MetricsType | String | No | JVM |
The metric type of the Application Monitoring or Browser Monitoring alert rule. For more information, see the following tables. |
| Filters | String | No | {"DimFilters": [ { "FilterOpt": "ALL", "FilterValues": [], "FilterKey": "rootIp" } ] } |
The filter conditions of the Application Monitoring or Browser Monitoring alert rule. Format: Valid values of FilterOpt:
|
| AlertRuleContent | String | No | { "Condition": "OR", "AlertRuleItems": [ { "Operator": "CURRENT_LTE", "MetricKey": "appstat.jvm.threadcount", "Value": 1000, "Aggregate": "AVG", "N": 1 } ] } |
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. { "Condition": "OR", "AlertRuleItems": [ { "Operator": "CURRENT_LTE", "MetricKey":
"appstat.jvm.threadcount", "Value": 1000, "Aggregate": "AVG", "N": 1 } ] }Note The conditional fields vary depending on the values of the MetricsType and AlertRuleItems.MetricKey parameters. 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.
|
| AlertCheckType | String | No | STATIC |
The alert check type of the Prometheus alert rule.
|
| ClusterId | String | No | ceba9b9ea5b924dd0b6726d2de6****** |
The cluster ID of the Prometheus alert rule. |
| AlertGroup | Long | No | -1 |
The alert contact group ID of the Prometheus alert rule.
|
| PromQL | String | No | node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100 |
The PromQL statement of the Prometheus alert rule. |
| Duration | Long | No | 1 |
The duration of the Prometheus alert rule. Unit: minutes. |
| Level | String | No | P2 |
The level of the Prometheus alert rule.
|
| Message | String | No | Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} Memory usage > 80%, Current value {{ printf \\\"%.2f\\\" $value }}% |
The alert message of the Prometheus alert rule. |
| Labels | String | No | [ { Value": "cms_polardb", "Name": "_aliyun_cloud_product" } ] |
The tags of the Prometheus alert rule. |
| Annotations | String | No | [ { "Value": "PolarDB slow queries", "Name": "_aliyun_display_name" } |
The annotations of the Prometheus alert rule. |
| MetricsKey | String | No | pop.status.error |
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.
|
Description of the AlertRuleContent parameter
{
"Condition": "OR",
"AlertRuleItems": [
{ "Operator": "CURRENT_LTE",
"MetricKey": "appstat.jvm.threadcount",
"Value": 1000,
"Aggregate": "AVG",
"N": 1
}
]
}
- Condition: the relationship between multiple alert conditions.
- OR: meets any of the specified conditions.
- AND: meets all the specified conditions.
- Operator: the comparison operator that is used to compare the metric value with the
threshold.
- CURRENT_GTE: greater than or equal to
- CURRENT_LTE: less than or equal to
- PREVIOUS_UP: the minute-to-minute increase percentage
- PREVIOUS_DOWN: the minute-to-minute decrease percentage
- HOH_UP: the increase percentage compared with the previous hour
- HOH_DOWN: the decrease percentage compared with the previous hour
- DOD_UP: the increase percentage compared with the last day
- DOD_DOWN: the decrease percentage compared with the last day
- MetricKey: the metric of the alert condition. Valid values of the MetricKey parameter vary depending on the value of the MetricsType parameter. For more information about the correspondence between the two parameters, see the following tables.
- Value: the threshold of the alert condition.
- Aggregate: the aggregation method of the alert condition.
- AVG: calculates the average value
- SUM: calculates the total value
- MAX: selects the maximum value
- MIN: selects the minimum value
- N: last N minutes.
Correspondence between MetricsType and AlertRuleContent.AlertRuleItems.MetricKey for Application Monitoring
|
MetricsType |
Metric type |
AlertRuleContent.AlertRuleItems.MetricKey |
|---|---|---|
|
jvm |
JVM monitoring |
|
|
saehost |
SAE host monitoring |
|
|
txn_db |
SQL metrics |
|
|
db |
Database metrics |
|
|
threadpool |
Thread pool monitoring |
|
|
exception |
Abnormal API calls |
|
|
txn_type |
Application call types |
|
|
txn |
Application calls |
|
|
host |
Host monitoring |
|
Correspondence between MetricsType and AlertRuleContent.AlertRuleItems.MetricKey for Browser Monitoring
|
MetricsType |
Metric type |
AlertRuleContent.AlertRuleItems.MetricKey |
|---|---|---|
|
api |
API metrics |
|
|
page.api |
Page API metrics |
|
|
page |
Page metrics |
|
|
custom |
Custom metrics |
|
Correspondence between AlertGroup and MetricsKey for Prometheus Service
|
AlertGroup |
Alert contact group |
MetricsKey |
|---|---|---|
|
1 |
Kubernetes load |
|
|
15 |
Kubernetes nodes |
|
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| RequestId | String | 337B8F7E-0A64-5768-9225-E9B3CF****** |
The ID of the request. |
| AlertRule | Object |
The object of the alert rule. |
|
| AlertId | Float | 5510445 |
The ID of the alert rule. |
| AlertName | String | arms-test |
The name of the alert rule. |
| UserId | String | 1131971649****** |
The ID of the Alibaba Cloud account. |
| RegionId | String | cn-hangzhou |
The ID of the region. |
| AlertType | String | APPLICATION_MONITORING_ALERT_RULE |
The type of the alert rule. Valid values:
|
| AlertStatus | String | RUNNING |
The status of the alert rule.
Note The PAUSED status indicates that the alert rule is abnormal and is actively paused by the system.
The alert rule may be paused because that it is not unique or the associated cluster
has been deleted.
|
| CreatedTime | Long | 1641438611000 |
The time when the alert rule was created. |
| UpdatedTime | Long | 1641438611000 |
The time when the alert rule was updated. |
| Extend | String | {\"alarmContext\":\"{\\\"content\\\":\\\Alert name: $Alert name\\\\nFilter condition: $Filter condition\\\\nAlert time: $Alert time\\\\nAlert content: $Alert content\\\\nNote: Before you receive an email to clear the alert, the alert is still active and we will remind you again 24 hours later. \\\",\\\"subTitle\\\":\\\"\\\"}\",\"alertWays\":\"[0,1]\",\"contactGroupIds\":\"381,5075\",\"notice\":\"{\\\"endTime\\\":1480607940000,\\\"noticeEndTime\\\":1480607940000,\\\"noticeStartTime\\\":1480521600000,\\\"startTime\\\":1480521600000}\"} |
The extended field. |
| NotifyStrategy | String | ALERT_MANAGER |
The name of the notification policy. |
| Pids | Array of String | b590lhguqs@40d8deedfa9****** |
The PID of the application. |
| AutoAddNewApplication | Boolean | false |
Indicates whether the alert rule is applied to new applications that are created in Application Monitoring or Browser Monitoring.
|
| MetricsType | String | JVM |
The metric type of the Application Monitoring or Browser Monitoring alert rule. |
| AlertRuleContent | Object |
The content of the Application Monitoring or Browser Monitoring alert rule. |
|
| Condition | String | "|" |
The relationship between multiple alert conditions specified for the Application Monitoring or Browser Monitoring alert rule.
|
| AlertRuleItems | Array of alertRuleItems |
The trigger conditions of the Application Monitoring or Browser Monitoring alert rule. |
|
| N | Float | 1 |
Indicates the last N minutes. |
| MetricKey | String | appstat.jvm.non_heap_used |
The metric of the alert condition. |
| Aggregate | String | AVG |
The aggregation method of the alert condition.
|
| Operator | String | CURRENT_GTE |
The comparison operator that is used to compare the metric value with the threshold.
|
| Value | String | 1 |
The threshold of the alert condition. |
| Filters | Object |
The filter conditions of the Application Monitoring or Browser Monitoring alert rule. |
|
| DimFilters | Array of dimFilters |
The information about each filter condition of the Application Monitoring or Browser Monitoring alert rule. |
|
| FilterKey | String | rootIp |
The key of the filter condition. |
| FilterOpt | String | ALL |
The logical operator of the filter condition. |
| FilterValues | Array of String | [] |
The value of the filter condition. |
| CustomSLSFilters | Array of customSLSFilters |
The custom filter condition of the Browser Monitoring alert rule. |
|
| Key | String | username |
The key of the filter condition. |
| Opt | String | = |
The logical operator of the filter condition.
|
| Value | String | test |
The value of the filter condition. |
| T | String | null |
This field is used only to distinguish the type of Browser Monitoring logs. Other filter conditions do not include this field. |
| Show | Boolean | false |
Indicates whether this filter condition is displayed on the frontend. |
| CustomSLSGroupByDimensions | Array of String | ["page"] |
The value of the aggregation dimension. |
| CustomSLSWheres | Array of String | ["t like '%api%'"] |
The value of the custom filter condition. |
| AlertCheckType | String | STATIC |
The alert check type of the Prometheus alert rule.
|
| ClusterId | String | ceba9b9ea5b924dd0b6726d2de6****** |
The cluster ID of the Prometheus alert rule. |
| AlertGroup | Long | -1 |
The alert contact group ID of the Prometheus alert rule.
|
| PromQL | String | node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100 |
The PromQL statement of the Prometheus alert rule. |
| Duration | String | 1 |
The duration of the Prometheus alert rule. Unit: minutes. |
| Level | String | P2 |
The level of the Prometheus alert rule.
|
| Message | String | Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} Memory usage > 80%, Current value {{ printf \\\"%.2f\\\" $value }}% |
The alert message of the Prometheus alert rule. |
| Labels | Array of labels |
The tags of the Prometheus alert rule. |
|
| Name | String | 123 |
The key of the tag. |
| Value | String | abc |
The value of the tag. |
| Annotations | Array of annotations |
The annotations of the Prometheus alert rule. |
|
| Name | String | 123 |
The key of the annotation. |
| Value | String | abc |
The value of the annotation. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateOrUpdateAlertRule
&AlertId=123
&AlertName=test-alert
&RegionId=cn-hangzhou
&AlertType=APPLICATION_MONITORING_ALERT_RULE
&AlertStatus=RUNNING
&NotifyStrategy=null
&Pids=b590lhguqs@40d8deedfa9******
&AutoAddNewApplication=false
&MetricsType=JVM
&Filters={ "DimFilters": [ { "FilterOpt": "ALL", "FilterValues": [], "FilterKey": "rootIp" } ] }
&AlertRuleContent={ "Condition": "OR", "AlertRuleItems": [ { "Operator": "CURRENT_LTE", "MetricKey": "appstat.jvm.threadcount", "Value": 1000, "Aggregate": "AVG", "N": 1 } ] }
&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 > 80%, Current value {{ printf \\\"%.2f\\\" $value }}%
&Labels=[ { Value": "cms_polardb", "Name": "_aliyun_cloud_product" } ]
&Annotations=[ { "Value": "PolarDB slow queries", "Name": "_aliyun_display_name" }
&Common request parametersSample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateOrUpdateAlertRuleResponse>
<RequestId>337B8F7E-0A64-5768-9225-E9B3CF******</RequestId>
<AlertRule>
<AlertId>5510445</AlertId>
<AlertName>arms-test</AlertName>
<UserId>1131971649******</UserId>
<RegionId>cn-hangzhou</RegionId>
<AlertType>APPLICATION_MONITORING_ALERT_RULE</AlertType>
<AlertStatus>RUNNING</AlertStatus>
<CreatedTime>1641438611000</CreatedTime>
<UpdatedTime>1641438611000</UpdatedTime>
<Extend>{\"alarmContext\":\"{\\\"content\\\":\\\Alert name: $Alert name\\\\nFilter condition: $Filter condition\\\\nAlert time: $Alert time\\\\nAlert content: $Alert content\\\\nNote: Before you receive an email to clear the alert, the alert is still active and we will remind you again 24 hours later. \\\",\\\"subTitle\\\":\\\"\\\"}\",\"alertWays\":\"[0,1]\",\"contactGroupIds\":\"381,5075\",\"notice\":\"{\\\"endTime\\\":1480607940000,\\\"noticeEndTime\\\":1480607940000,\\\"noticeStartTime\\\":1480521600000,\\\"startTime\\\":1480521600000}\"}</Extend>
<NotifyStrategy>ALERT_MANAGER</NotifyStrategy>
<Pids>b590lhguqs@40d8deedfa9******</Pids>
<AutoAddNewApplication>false</AutoAddNewApplication>
<MetricsType>JVM</MetricsType>
<AlertRuleContent>
<Condition>"|"</Condition>
<AlertRuleItems>
<N>1</N>
<MetricKey>appstat.jvm.non_heap_used</MetricKey>
<Aggregate>AVG</Aggregate>
<Operator>CURRENT_GTE</Operator>
<Value>1</Value>
</AlertRuleItems>
</AlertRuleContent>
<Filters>
<DimFilters>
<FilterKey>rootIp</FilterKey>
<FilterOpt>ALL</FilterOpt>
<FilterValues>[]</FilterValues>
</DimFilters>
<CustomSLSFilters>
<Key>username</Key>
<Opt>=</Opt>
<Value>test</Value>
<T>null</T>
<Show>false</Show>
</CustomSLSFilters>
<CustomSLSGroupByDimensions>["page"]</CustomSLSGroupByDimensions>
<CustomSLSWheres>["t like '%api%'"]</CustomSLSWheres>
</Filters>
<AlertCheckType>STATIC</AlertCheckType>
<ClusterId>ceba9b9ea5b924dd0b6726d2de6******</ClusterId>
<AlertGroup>-1</AlertGroup>
<PromQL>node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100</PromQL>
<Duration>1</Duration>
<Level>P2</Level>
<Message>Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} Memory usage > 80%, Current value {{ printf \\\"%.2f\\\" $value }}%</Message>
<Labels>
<Name>123</Name>
<Value>abc</Value>
</Labels>
<Annotations>
<Name>123</Name>
<Value>abc</Value>
</Annotations>
</AlertRule>
</CreateOrUpdateAlertRuleResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"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: Before you receive an email to clear the alert, the alert is still active and we will remind you again 24 hours later. \\\\\\\",\\\\\\\"subTitle\\\\\\\":\\\\\\\"\\\\\\\"}\\\",\\\"alertWays\\\":\\\"[0,1]\\\",\\\"contactGroupIds\\\":\\\"381,5075\\\",\\\"notice\\\":\\\"{\\\\\\\"endTime\\\\\\\":1480607940000,\\\\\\\"noticeEndTime\\\\\\\":1480607940000,\\\\\\\"noticeStartTime\\\\\\\":1480521600000,\\\\\\\"startTime\\\\\\\":1480521600000}\\\"}",
"NotifyStrategy" : "ALERT_MANAGER",
"Pids" : [ "b590lhguqs@40d8deedfa9******" ],
"AutoAddNewApplication" : false,
"MetricsType" : "JVM",
"AlertRuleContent" : {
"Condition" : "\"|\"",
"AlertRuleItems" : [ {
"N" : 1,
"MetricKey" : "appstat.jvm.non_heap_used",
"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 > 80%, Current value {{ printf \\\\\\\"%.2f\\\\\\\" $value }}%",
"Labels" : [ {
"Name" : "123",
"Value" : "abc"
} ],
"Annotations" : [ {
"Name" : "123",
"Value" : "abc"
} ]
}
}Error codes
For a list of error codes, visit the API Error Center.