All Products
Search
Document Center

Application Real-Time Monitoring Service:CreateOrUpdateAlertRule

Last Updated:Nov 05, 2024

Creates or modifies an alert rule.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
arms:CreateAlertRulescreate
  • AlertRule
    acs:arms:{#regionId}:{#AccountId}:alertrule/{#AlertRuled}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
AlertIdlongNo

The ID of the alert rule.

  • If you do not specify this parameter, a new alert rule is created.
  • If you specify this parameter, the specified alert rule is modified.
546xxx
AlertNamestringYes

The name of the alert rule.

Alert Rule Demo
RegionIdstringYes

The region ID.

cn-hangzhou
AlertTypestringYes

The type of the alert rule. Valid values:

  • APPLICATION_MONITORING_ALERT_RULE: alert rule for Application Monitoring
  • BROWSER_MONITORING_ALERT_RULE: alert rule for Browser Monitoring
  • PROMETHEUS_MONITORING_ALERT_RULE: alert rule for Managed Service for Prometheus
  • XTRACE_MONITORING_ALERT_RULE: alert rule for Managed Service for OpenTelemetry
  • EBPF_MONITORING_ALERT_RULE: alert rule for Application Monitoring eBPF Edition
  • RUM_MONITORING_ALERT_RULE: alert rule for Real User Monitoring
APPLICATION_MONITORING_ALERT_RULE
AlertStatusstringNo

The status of the alert rule. Valid values:

  • RUNNING (default)
  • STOPPED
RUNNING
NotifyStrategystringNo

The notification policy.

  • If you set this parameter to null, no notification policy is specified. After you create an alert rule, you can create a notification policy and specify match rules and match conditions. For example, you can specify the name of the alert rule as the match condition. When the alert rule is triggered, an alert event is generated and an alert notification is sent to the contacts or contact groups that are specified in the notification policy.
  • To specify a notification policy, set this parameter to the ID of the notification policy. Application Real-Time Monitoring Service (ARMS) automatically adds a match rule to the notification policy and specifies the ID of the alert rule as the match condition. The name of the alert rule is also displayed. This way, the alert events that are generated based on the alert rule can be matched by the specified notification policy.
569xxx
PidsstringNo

The process ID (PID) that is associated with the Application Monitoring or Browser Monitoring alert rule.

["b590lhguqs@40d8deedfa9******"]
AutoAddNewApplicationbooleanNo

Specifies whether to apply the alert rule to new applications that are created in Application Monitoring or Browser Monitoring. Valid values:

  • true: enables the health check feature.
  • false: disables the automatic backup feature.
false
MetricsTypestringNo

The metric type of the Application Monitoring or Browser Monitoring alert rule. For more information, see the following table.

jvm
FiltersstringNo

The filter conditions of the Application Monitoring or Browser Monitoring alert rule. Format:

"DimFilters": [ 
{ 
 "FilterOpt": "ALL",
"FilterValues": [],         //The value of the filter condition.
"FilterKey": "rootIp"     //The key of the filter condition.
}
]

Valid values of FilterOpt:

  • STATIC: matches the value of the specified dimension.
  • ALL: traverses all dimension values. Dynamic thresholds do not support traversal.
  • DISABLE: aggregates the values of all dimensions.
{"DimFilters": [ { "FilterOpt": "ALL", "FilterValues": [], "FilterKey": "rootIp" } ] }
AlertRuleContentstringNo

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": 10,
                  "Tolerability": 169
            } 
       ]  
  }
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 } ] }
AlertCheckTypestringNo

The alert check type of the Prometheus alert rule. Valid values:

  • STATIC: a static threshold value. If you set the parameter to STATIC, you must specify the MetricsKey parameter. For more information, see the Correspondence between AlertGroup and MetricsKey for Prometheus Service table.
  • CUSTOM: a custom PromQL statement. If you set the parameter to CUSTOM, you must specify the PromQL, Duration, and Message parameters to create a Prometheus alert rule.
STATIC
ClusterIdstringNo

The ID of the monitored cluster.

ceba9b9ea5b924dd0b6726d2de6******
AlertGrouplongNo

The alert contact group ID of the Prometheus alert rule. Valid values:

  • -1: custom PromQL
  • 1: Kubernetes load
  • 15: Kubernetes node
-1
PromQLstringNo

The PromQL statement of the Prometheus alert rule.

node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100
DurationlongNo

The duration of the Prometheus alert rule, in minutes, in the range of [0,1440].

1
LevelstringNo

The severity level of the Prometheus alert rule.

  • P1: Alert notifications are sent for major issues that affect the availability of core business, have a huge impact, and may lead to serious consequences.
  • P2: Alert notifications are sent for service errors that affect the system availability with relatively limited impact.
  • P3: Alert notifications are sent for issues that may cause service errors or negative effects, or alert notifications for services that are relatively less important.
  • P4: Alert notifications are sent for low-priority issues that do not affect your business.
  • Default: Alert notifications are sent regardless of alert levels.
P2
MessagestringNo

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 }}%
LabelsstringNo

The tags of the Prometheus alert rule.

[ { "Value": "cms_polardb", "Name": "_aliyun_cloud_product" } ]
AnnotationsstringNo

The annotations of the Prometheus alert rule.

\[ { "Value": "PolarDB slow queries", "Name": "\_aliyun_display_name" }
MetricsKeystringNo

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
Tagsarray<object>No

The list of tags.

objectNo
KeystringNo

The tag key.

owner
ValuestringNo

The tag value.

John
MarkTagsarray<object>No

Application Tags. Used for application monitoring alert rules, to filter applications associated with alert rules.

objectNo

Associated Application Tags.

KeystringNo

The Tag Key.

service
ValuestringNo

The Tag Value.

proudct
DataConfigstringNo

Data Configuration. The dataRevision field specifies the data repair method when there is no data for the metric.

  • Fill with zero: 0
  • Fill with one: 1
  • Fill with null: 2 (default, does not trigger an alarm)
{ "dataRevision": 2 }
NoticestringNo

The effective time and notification time. This parameter is used to be compatible with the old version of the rule.

-
AlertPiplinesstringNo

The configuration of the alert sending channel. This parameter is used to be compatible with the old version of the rule.

-
NotifyModestringNo

The notification mode. You can specify the normal mode or simple mode.

  • DIRECTED_MODE
  • NORMAL_MODE
NORMAL_MODE
ProductstringNo

The product code. If you specify this parameter when you create a Prometheus alert rule, the backend checks whether the product exists.

clickhouse
AutoAddTargetConfigstringNo

The configurations that are automatically appended to monitor the application based on the specified alert rule.

  • autoAddMatchType:

    the matching mode. Valid values: REGULAR and NOT_REGULAR.

  • autoAddMatchExp: the regular expression

{\"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

ParameterTypeDescriptionExample
object

The returned data.

RequestIdstring

The request ID.

337B8F7E-0A64-5768-9225-E9B3CF******
AlertRuleobject

The details of the alert rule.

AlertIdfloat

The ID of the alert rule.

5510445
AlertNamestring

The name of the alert rule.

arms-test
UserIdstring

The ID of the Alibaba Cloud account.

1131971649******
RegionIdstring

The region ID.

cn-hangzhou
AlertTypestring

The type of the alert rule. Valid values:

  • APPLICATION_MONITORING_ALERT_RULE: alert rule for Application Monitoring
  • BROWSER_MONITORING_ALERT_RULE: alert rule for Browser Monitoring
  • PROMETHEUS_MONITORING_ALERT_RULE: alert rule for Prometheus Service
APPLICATION_MONITORING_ALERT_RULE
AlertStatusstring

The status of the alert rule. Valid values:

  • RUNNING
  • STOPPED
  • PAUSED
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.
RUNNING
CreatedTimelong

The timestamp generated when the alert rule was created. Unit: seconds.

1641438611000
UpdatedTimelong

The timestamp generated when the alert rule was updated. Unit: seconds.

1641438611000
Extendstring

The extended fields.

{\\"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}\\"}
NotifyStrategystring

The name of the notification policy.

ALERT_MANAGER
Pidsarray

The process ID (PID) that was associated with the Application Monitoring or Browser Monitoring alert rule.

pidsstring

The PID of the application.

b590lhguqs@40d8deedfa9******
AutoAddNewApplicationboolean

Indicates whether the alert rule was applied to new applications that were created in Application Monitoring or Browser Monitoring. Valid values:

  • true: enables the health check feature.
  • false: disables the automatic backup feature.
false
MetricsTypestring

The metric type of the Application Monitoring or Browser Monitoring alert rule.

JVM
AlertRuleContentobject

The content of the Application Monitoring or Browser Monitoring alert rule.

Conditionstring

The relationship between multiple alert conditions that were specified for the Application Monitoring or Browser Monitoring alert rule. Valid values:

  • OR: meets any of the specified conditions.
  • AND: meets all the specified conditions.
"|"
AlertRuleItemsarray<object>

The trigger conditions of the Application Monitoring or Browser Monitoring alert rule.

alertRuleItemsobject

The details of the alert condition.

Nfloat

Indicates the last N minutes.

1
MetricKeystring

The metric of the alert condition.

appstat.jvm.non_heap_used
Aggregatestring

The aggregation method of the alert condition. Valid values:

  • AVG: calculates the average value
  • SUM: calculates the total value
  • MAX: selects the maximum value
  • MIN: selects the minimum value
AVG
Operatorstring

The comparison operator that was used to compare the metric value with the threshold. Valid values:

  • CURRENT_GTE: greater than or equal to
  • CURRENT_LTE: less than or equal to
  • PREVIOUS_UP: the increase percentage compared with the last period
  • PREVIOUS_DOWN: the decrease percentage compared with the last period
  • HOH_UP: the increase percentage compared with the last hour
  • HOH_DOWN: the decrease percentage compared with the last hour
  • DOD_UP: the increase percentage compared with the last day
  • DOD_DOWN: the decrease percentage compared with the last day
CURRENT_GTE
Valuestring

The threshold of the alert condition.

1
Filtersobject

The filter conditions of the Application Monitoring or Browser Monitoring alert rule.

DimFiltersarray<object>

The information about each filter condition of the Application Monitoring or Browser Monitoring alert rule.

dimFiltersobject

The details of the filter condition.

FilterKeystring

The key of the filter condition.

rootIp
FilterOptstring

The logical operator of the filter condition.

ALL
FilterValuesarray

The details of the filter condition.

filterValuesstring

The value of the filter condition.

[]
CustomSLSFiltersarray<object>

The custom filter condition of the Browser Monitoring alert rule.

customSLSFiltersobject

The details of the custom filter condition.

Keystring

The key of the filter condition.

username
Optstring

The logical operator of the filter condition. Valid values:

  • =: equal to
  • not: not equal to
=
Valuestring

The value of the filter condition.

test
Tstring

The log type of Browser Monitoring. This field was not included in other filter conditions.

null
Showboolean

Indicates whether this filter condition was displayed on the frontend.

false
CustomSLSGroupByDimensionsarray

The information of the aggregation dimension.

customSLSGroupByDimensionsstring

The value of the aggregation dimension.

["page"]
CustomSLSWheresarray

The details of the custom filter condition.

customSLSWheresstring

The value of the custom filter condition.

["t like '%api%'"]
AlertCheckTypestring

The alert check type of the Prometheus alert rule. Valid values:

  • STATIC: a static threshold value.
  • CUSTOM: a custom PromQL statement.
STATIC
ClusterIdstring

The ID of the monitored cluster.

ceba9b9ea5b924dd0b6726d2de6******
AlertGrouplong

The alert contact group ID of the Prometheus alert rule. Valid values:

  • -1: custom PromQL
  • 1: Kubernetes load
  • 15: Kubernetes node
-1
PromQLstring

The PromQL statement of the Prometheus alert rule.

node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100
Durationstring

The duration of the Prometheus alert rule. Unit: minutes.

1
Levelstring

The severity level of the Prometheus alert rule.

  • P1: Alert notifications are sent for major issues that affect the availability of core business, have a huge impact, and may lead to serious consequences.
  • P2: Alert notifications are sent for service errors that affect the system availability with relatively limited impact.
  • P3: Alert notifications are sent for issues that may cause service errors or negative effects, or alert notifications for services that are relatively less important.
  • P4: Alert notifications are sent for low-priority issues that do not affect your business.
  • Default: Alert notifications are sent regardless of alert levels.
P2
Messagestring

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 }}%
Labelsarray<object>

The tags of the Prometheus alert rule.

labelsobject

The tag struct.

Namestring

The tag key.

123
Valuestring

The tag value.

abc
Annotationsarray<object>

The annotations of the Prometheus alert rule.

annotationsobject

The annotation struct.

Namestring

The key of the annotation.

123
Valuestring

The value of the annotation.

abc
Tagsarray<object>

The list of tags.

Tagobject
Keystring

The tag key.

owner
Valuestring

The tag value.

John
NotifyModestring

Notification Mode.

NORMAL_MODE

Examples

Sample success responses

JSONformat

{
  "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 timeSummary of changesOperation
2024-05-07The request parameters of the API has changedView Change Details
2024-04-29The request parameters of the API has changedView Change Details
2023-12-18The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-10-20The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-10-17The response structure of the API has changedView Change Details
2023-10-16The request parameters of the API has changedView Change Details
2023-10-11The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-09-14The request parameters of the API has changedView Change Details
2023-08-24The request parameters of the API has changedView Change Details
2023-05-11The request parameters of the API has changed. The response structure of the API has changedView Change Details