All Products
Search
Document Center

Cloud Monitor:CreateHostAvailability

Last Updated:Jun 13, 2026

Creates an availability monitoring task by calling the CreateHostAvailability operation.

Operation description

This topic provides an example of how to create an availability monitoring task named task1 with the detection type set to HTTP in application group 123456. Alert notifications are sent by email and DingTalk chatbot.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cms:CreateHostAvailability

create

*HostAvailability

acs:cms::{#accountId}:group/{#groupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

GroupId

integer

Yes

The ID of the application group.

123456

TaskName

string

Yes

The name of the availability monitoring task. The name must be 4 to 100 characters in length and can contain letters, digits, underscores (_), and Chinese characters.

task1

TaskScope

string

No

The detection scope of the availability monitoring task. Valid values:

  • GROUP: uses all ECS instances in the current application group as detection probes.

  • GROUP_SPEC_INSTANCE: uses specified ECS instances in the current application group as detection probes. If you set this parameter to GROUP_SPEC_INSTANCE, you must also set InstanceList to specify the ECS instances that initiate detection.

GROUP

TaskType

string

Yes

The detection type of the availability monitoring task. Valid values:

  • PING

  • TELNET

  • HTTP.

HTTP

TaskOption.HttpURI

string

No

HTTP、Telnet 探测类型的探测 URI 地址。

https://www.aliyun.com telnet://127.0.0.1:80

TaskOption.TelnetOrPingHost

string

No

探测的域名或地址。

Note

如果探测任务类型为 PING,则需要设置该参数。

www.aliyun.com

TaskOption.HttpResponseCharset

string

No

HTTP 探测类型的响应字符集。

Note

仅支持 UTF-8。

UTF-8

TaskOption.HttpPostContent

string

No

HTTP 探测类型探测请求的 Post 内容。

params1=paramsValue1

TaskOption.HttpResponseMatchContent

string

No

匹配响应的内容。

ok

TaskOption.HttpMethod

string

No

探测类型的方法。取值:

  • GET

  • POST

  • HEAD

Note

如果任务的探测类型为 HTTP,则需要设置该参数。

GET

TaskOption.HttpNegative

boolean

No

匹配 HTTP 响应内容的报警规则。取值:

  • true:如果 HTTP 响应内容包含设置的报警规则,则报警。

  • false:如果 HTTP 响应内容不包含设置的报警规则,则报警。

Note

如果任务的探测类型为 HTTP,则该参数生效。

true

TaskOption.HttpHeader

string

No

HTTP 请求的 Header。格式为参数名:参数,多个参数之间用回车符分隔,例如:

params1:value1
params2:value2

token:testTokenValue

TaskOption.Interval

integer

No

探测频率。单位:秒。取值:15、30、60、120、300、900、1800 和 3600。

Note

仅 3.5.1 及以上版本的云监控插件支持该参数。

60

AlertConfig.NotifyType

integer

Yes

报警通知类型。取值:

0:邮件+钉钉机器人。

0

AlertConfig.StartTime

integer

No

报警生效的开始时间。取值范围:0~23。

例如:AlertConfig.StartTime为 0,AlertConfig.EndTime为 22,表示报警生效时间为 00:00:00 至 22:00:00。

Note

如果报警不在生效时间内,则超过阈值也不会发送报警通知。

0

AlertConfig.EndTime

integer

No

报警生效的结束时间。取值范围:0~23。

例如:AlertConfig.StartTime为 0,AlertConfig.EndTime为 22,表示报警生效时间为 00:00:00 至 22:00:00。

Note

如果报警不在生效时间内,则超过阈值也不会发送报警通知。

22

AlertConfig.SilenceTime

integer

No

通道沉默时间。单位:秒,默认值:86400(1 天)。

86400

AlertConfig.WebHook

string

No

URL 回调地址。

https://www.aliyun.com/webhook.json

AlertConfigEscalationList

array<object>

Yes

None.

object

No

None.

MetricName

string

Yes

The metric for the alert. Valid values of N: 1 to 21. Valid values:

  • HttpStatus: HTTP status code.

  • HttpLatency: HTTP latency.

  • TelnetStatus: Telnet status code.

  • TelnetLatency: Telnet latency.

  • PingLostRate: Ping packet loss rate.

HttpStatus

Value

string

No

The alert threshold. Valid values of N: 1 to 21.

90

Times

integer

No

The number of alert retries. Valid values of N: 1 to 21.

3

Operator

string

No

The comparison operator for the alert rule. Valid values of N: 1 to 21. Valid values:

  • >

  • >=

  • <

  • <=

  • =.

>

Aggregate

string

No

The statistical method for the alert. Valid values of N: 1 to 21. The valid values vary based on the metric:

  • HttpStatus: Value.

  • HttpLatency: Average.

  • TelnetStatus: Value.

  • TelnetLatency: Average.

  • PingLostRate: Average.

Note

The statistical method for status code metrics is the raw value (Value). The statistical method for latency or packet loss rate metrics is the average value (Average).

Value

InstanceList

array

No

The list of ECS instances that initiate detection. Valid values of N: 1 to 21.

Note

Set this parameter when TaskScope is set to GROUP_SPEC_INSTANCE.

i-absdfkwl321****

string

No

The list of ECS instances that initiate detection. Valid values of N: 1 to 21.

Note

Set this parameter when TaskScope is set to GROUP_SPEC_INSTANCE.

2

AlertConfigTargetList

array<object>

No

The alert trigger targets.

object

No

The alert trigger targets.

Id

string

No

The ID of the alert trigger target.

1

Arn

string

No

The Alibaba Cloud Resource Name (ARN) of the resource. Format: acs:{AbbreviatedServiceName}:{regionId}:{userId}:/{ResourceType}/{ResourceName}/message. Example: acs:mns:ap-southeast-1:120886317861****:/queues/test123/message. The following list describes the parameters:

  • {AbbreviatedServiceName}: Only Simple Message Queue (formerly MNS) is supported.

  • {userId}: The Alibaba Cloud account ID.

  • {regionId}: The region where the Simple Message Queue (formerly MNS) queue or topic resides.

  • {ResourceType}: The type of the resource that accepts alerts. Valid values:

    • queues: queue.

    • topics: topic.

  • {ResourceName}: The name of the resource.

    • If the resource type is queues, the resource name is the queue name.

    • If the resource type is topics, the resource name is the topic name.

acs:mns:cn-hangzhou:120886317861****:/queues/test/message

Level

string

No

The alert level. Valid values:

  • INFO: information.

  • WARN: warning.

  • CRITICAL: critical.

["INFO", "WARN", "CRITICAL"]

JsonParams

string

No

The JSON-formatted parameters for the alert callback.

{"customField1":"value1","customField2":"$.name"}

For more information about common request parameters, see Common parameters.

Response elements

Element

Type

Description

Example

object

Code

string

The status code.

Note

A value of 200 indicates success.

200

Message

string

The error message.

The specified resource is not found.

RequestId

string

The request ID.

ACBDBB40-DFB6-4F4C-8957-51FFB233969C

TaskId

integer

The ID of the availability monitoring task.

12345

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

true

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "The specified resource is not found.",
  "RequestId": "ACBDBB40-DFB6-4F4C-8957-51FFB233969C",
  "TaskId": 12345,
  "Success": true
}

Error codes

HTTP status code

Error code

Error message

Description

400 ParameterInvalid Parameter invalid.
412 ResouceOverLimit The task over limit
500 InternalError The request processing has failed due to some unknown error.
403 AccessForbidden User not authorized to operate on the specified resource.
404 ResourceNotFound %s
409 ResourceConflict Concurrent modification of resources.
409 ResourceExist Resources already exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.