You can call this operation to add or modify the message resource of an alert rule.

This operation only supports Message Notification Service (MNS) as the message service.

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 resource description 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 this 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 a queue if the resource type is queues, or the name of a topic if the type is topics.
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 status code.

Note The status code 200 indicates a successful call, whereas any other status code indicates a failed call.
FailData Struct

The list of error data. If any error occurs, the specific error information will be returned. If no error occurs, this field will not be returned.

Targets Array

The list of the message resources that failed to be added or modified.

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

The resource description 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 this 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 a queue if the resource type is queues, or the name of a topic if the type is topics.
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, which can be used for troubleshooting.

Success Boolean true

Indicates whether the operation was successful. Valid values:

  • true: indicates that the operation was successful.
  • false: indicates that the operation failed.

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.