Creates an application group based on the tags of cloud resources.

This operation is available for Elastic Compute Service (ECS), ApsaraDB RDS, and Server Load Balancer (SLB).

This topic provides an example to show how to create an application group for resources whose tag key is ecs_instance. In this example, the alert contact group of the application group is ECS_Group.

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 CreateDynamicTagGroup

The operation that you want to perform. Set the value to CreateDynamicTagGroup.

TagKey String Yes ecs_instance

The tag keys of the cloud resources.

For more information about how to obtain tag keys, see DescribeTagKeyList.

ContactGroupList.N String Yes ECS_Group

The alert contact groups. Valid values of N: 1 to 100. The alert notifications of the application group are sent to the alert contacts that belong to the specified alert contact groups.

An alert contact group can contain one or more alert contacts. For information about how to create alert contacts and alert contact groups, see PutContact and PutContactGroup. For information about how to obtain alert contact groups, see DescribeContactGroupList.

MatchExpress.N.TagValueMatchFunction String No contains

The method that is used to match the tag values of the cloud resources. In this example, set the value of N to 1. Valid values:

  • contains: contains
  • startWith: starts with a prefix
  • endWith: ends with a suffix
  • notContains: does not contain
  • equals: equals
  • all: matches all
Note If you set the MatchExpress.N.TagValueMatchFunction parameter, you must also set the MatchExpress.N.TagValue parameter.
MatchExpress.N.TagValue String No instance

The tag values of the cloud resources. In this example, set the value of N to 1.

Note If you set the MatchExpress.N.TagValueMatchFunction parameter, you must also set the MatchExpress.N.TagValue parameter.
MatchExpress.N.TagName String No appname

The keys of the tags that are used to create the application group. If a specified key is attached to multiple resources, the resources that have the same key-value pair are added to the same group.

TagRegionId String No cn-hangzhou

The ID of the region to which the tags belong.

EnableSubscribeEvent Boolean No true

Specifies whether the application group automatically subscribes to event notifications. If events whose severity level is critical or warning occur on resources in an application group, CloudMonitor sends alert notifications. Valid values:

  • true: The application group automatically subscribes to event notifications.
  • false (default value): The application group does not automatically subscribe to event notifications.
EnableInstallAgent Boolean No true

Specifies whether the CloudMonitor agent is automatically installed for the application group. CloudMonitor determines whether to automatically install the CloudMonitor agent for the hosts in an application group based on the value of this parameter. Valid values:

  • true: The CloudMonitor agent is automatically installed.
  • false (default value): The CloudMonitor agent is not automatically installed.
MatchExpressFilterRelation String No and

The relationship between the conditional expressions for the tag values of the cloud resources. Valid values:

  • and (default value)
  • or
TemplateIdList.N String No 70****

The IDs of the alert templates.

For more information about how to query alert template IDs, see DescribeMetricRuleTemplateList.

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 is successful.
Message String The specified resource is not found.

The error message.

RequestId String 84AC6F0B-7945-466A-AA44-99BB5A561F86

The ID of the request.

Success Boolean true

Indicates whether the call is successful. Valid values:

  • true: The call is successful.
  • false: The call fails.
Id String 2534dc0a-e3e5-4ae1-a2fc-75ef166c****

The ID of the tag matching rule.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateDynamicTagGroup
&TagKey=ecs_instance
&ContactGroupList.1=ECS_Group
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateDynamicTagGroupResponse>
	<RequestId>84AC6F0B-7945-466A-AA44-99BB5A561F86</RequestId>
	<Id>2534dc0a-e3e5-4ae1-a2fc-75ef166c****</Id>
	<Code>200</Code>
	<Success>true</Success>
</CreateDynamicTagGroupResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "84AC6F0B-7945-466A-AA44-99BB5A561F86",
  "Id" : "2534dc0a-e3e5-4ae1-a2fc-75ef166c****",
  "Code" : "200",
  "Success" : true
}

Error codes

HTTP status code Error code Error message Description
404 ResourceNotFound The specified resource is not found. The error message returned because the specified resource is not found.

For a list of error codes, see Service error codes.