Associates resources with a specified alert rule or modifies the resources that are associated with the alert rule.
Limit
This operation supports only Message Service (MNS) resources.
Usage notes
This topic provides an example on how to associate a resource with an alert rule whose
ID is ae06917_75a8c43178ab66****
. In this example, the Alibaba Cloud Resource Name (ARN) of the resource is acs:mns:cn-hangzhou:120886317861****:/queues/test/message
for an alert rule and the ID of the resource for which alerts are triggered is 1
. The response indicates that the resource is associated with the specified alert
rule.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | PutMetricRuleTargets |
The operation that you want to perform. Set the value to PutMetricRuleTargets. |
RuleId | String | Yes | ae06917_75a8c43178ab66**** |
The ID of the alert rule. For information about how to obtain the ID of an alert rule, see DescribeMetricRuleList. |
Targets.N.Id | String | Yes | 1 |
The ID of the resource for which alerts are triggered. For information about how to obtain the ID of a resource for which alerts are triggered, see DescribeMetricRuleTargets. |
Targets.N.Arn | String | Yes | acs:mns:cn-hangzhou:120886317861****:/queues/test/message |
The ARN of the resource. For information about how to obtain the ARN of a resource, see DescribeMetricRuleTargets. Format:
|
Targets.N.Level | String | No | ["INFO", "WARN", "CRITICAL"] |
The level of the alert. Valid values:
|
Targets.N.JsonParams | String | No | {"customField1":"value1","customField2":"$.name"} |
The parameters of the alert callback. The parameters are in the JSON format. |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | 200 |
The HTTP status code. Note The status code 200 indicates that the call was successful.
|
Message | String | The request processing has failed due to some unknown error. |
The error message. |
RequestId | String | 6A569B0D-9055-58AF-9E82-BAEAF95C0FD5 |
The ID of the request. |
Success | Boolean | true |
Indicates whether the call was successful. Valid values:
|
FailData | Object |
The list of resources that failed to be created or modified. |
|
Targets | Array of Target |
The information about the resource for which alerts are triggered. |
|
Target | |||
Id | String | 1 |
The ID of the resource for which alerts are triggered. |
Arn | String | acs:mns:cn-hangzhou:111:/queues/test/message |
The ARN of the resource. Format:
|
Level | String | ["INFO", "WARN", "CRITICAL"] |
The level of the alert. Valid values:
|
Examples
Sample requests
http(s)://[Endpoint]/?Action=PutMetricRuleTargets
&RuleId=ae06917_75a8c43178ab66****
&Targets.1.Arn=acs:mns:cn-hangzhou:120886317861****:/queues/test/message
&Targets.1.Id=1
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<PutMetricRuleTargetsResponse>
<RequestId>6A569B0D-9055-58AF-9E82-BAEAF95C0FD5</RequestId>
<Code>200</Code>
<Success>true</Success>
</PutMetricRuleTargetsResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "6A569B0D-9055-58AF-9E82-BAEAF95C0FD5",
"Code" : "200",
"Success" : true
}
Error codes
For a list of error codes, visit the API Error Center.