Adds or modifies the message resources of an alert rule.

This operation supports only Message Service (MNS) resources.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

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 rulexx12346

The ID of the alert rule.

Targets.N.Arn String Yes acs:mns:cn-hangzhou:111:/queues/test/message

The Alibaba Cloud Resource Name (ARN) of the resource in the format of acs:{Service name abbreviation}:{regionId}:{userId}:/{Message resource type}/{Resource name}/message. Example: acs:mns:cn-hangzhou:111:/queues/test/message.

  • {Service name abbreviation}: the abbreviation of the service name. Set the value to mns.
  • {regionId}: the region ID of the message queue or topic.
  • {userId}: the account ID of the user.
  • {Message resource type}: the type of the message resource. Valid values: queues and topics.
  • {Resource name}: the name of the message queue or topic.
Targets.N.Id String Yes 1

The ID of the message resource. The ID must be unique in the alert rule.

Targets.N.Level String No ["INFO", "WARN", "CRITICAL"]

The alert level, which is a JSON array. Valid values:

  • INFO
  • WARN
  • CRITICAL

Response parameters

Parameter Type Example Description
Code String 200

The HTTP status code.

Note The status code 200 indicates that the call was successful. Other status codes indicate that the call failed.
FailData Struct

The message resources that failed to be added or modified. If any error occurs, the specific error information is returned in this parameter. If no error occurs, this parameter is not be returned.

Targets Array

The message resources that failed to be added or modified.

Target
Arn String acs:mns:cn-hangzhou:111:/queues/test/message

The Alibaba Cloud Resource Name (ARN) of the resource in the format of acs:{Service name abbreviation}:{regionId}:{userId}:/{Message resource type}/{Resource name}/message. Example: acs:mns:cn-hangzhou:111:/queues/test/message.

  • {Service name abbreviation}: the abbreviation of the service name. The value is mns.
  • {regionId}: the region ID of the message queue or topic.
  • {userId}: the account ID of the user.
  • {Message resource type}: the type of the message resource. Valid values: queues and topics.
  • {Resource name}: the name of the message queue or topic.
Id String 1

The ID of the message resource.

Level String ["INFO", "WARN", "CRITICAL"]

The alert level, which is a JSON array. Valid values:

  • INFO
  • WARN
  • CRITICAL
Message String success

The returned message.

RequestId String 786E92D2-AC66-4250-B76F-F1E2FCDDBA1C

The ID of the request.

Success Boolean true

Indicates whether the call was successful. Valid values:

  • true: indicates a successful call.
  • false: indicates a failed call.

Examples

Sample requests

http(s)://[Endpoint]/?Action=PutMetricRuleTargets
&RuleId=rulexx12346
&<Common request parameters>

Sample success responses

XML format

<PutMetricRuleTargetsResponse>
      <Message>Success</Message>
      <Success>true</Success>
      <RequestId>786E92D2-AC66-4250-B76F-F1E2FCDDBA1C</RequestId>
      <FailData>
            <Targets>
                  <Arn>acs:mns:cn-hangzhou:111:/queues/test/message</Arn>
                  <Id>1</Id>
                  <Level>INFO</Level>
                  <Level>WARN</Level>
                  <Level>CRITICAL</Level>
            </Targets>
      </FailData>
</PutMetricRuleTargetsResponse>

JSON format

{
    "Code":"200",
    "Message":"Success",
    "Success":true,
    "RequestId":"786E92D2-AC66-4250-B76F-F1E2FCDDBA1C",
    "FailData":{
        "Targets":[
            {
                "Arn":"acs:mns:cn-hangzhou:111:/queues/test/message",
                "Id":1,
                "Level":["INFO", "WARN", "CRITICAL"]
            }
        ]
    }
}

Error codes

For a list of error codes, visit the API Error Center.