All Products
Search
Document Center

CloudMonitor:CreateHostAvailability

Last Updated:Mar 01, 2024

Creates an availability monitoring task.

Operation description

This topic provides an example on how to create an availability monitoring task named task1 in an application group named 123456. The TaskType parameter of the task is set to HTTP. After you start the task, the system sends alerts by using the specified email address and DingTalk chatbot.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
GroupIdlongYes

The ID of the application group.

123456
TaskNamestringYes

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

task1
TaskScopestringNo

The range of instances that are monitored by the availability monitoring task. Valid values:

  • GROUP: All Elastic Compute Service (ECS) instances in the application group are monitored.
  • GROUP_SPEC_INSTANCE: Specified ECS instances in the application group are monitored. The TaskScope parameter must be used in combination with the InstanceList.N parameter. The InstanceList.N parameter specifies the ECS instances to be monitored.
GROUP
TaskTypestringYes

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

  • PING
  • TELNET
  • HTTP
HTTP
TaskOption.HttpURIstringNo

The URI that you want to monitor. This parameter must be specified when TaskType is set to HTTP.

https://www.aliyun.com
TaskOption.TelnetOrPingHoststringNo

The domain name or IP address that you want to monitor.

Note This parameter must be specified when TaskType is set to PING or TELNET.
www.aliyun.com
TaskOption.HttpResponseCharsetstringNo

The character set that is used in the HTTP response.

Note Only UTF-8 is supported.
UTF-8
TaskOption.HttpPostContentstringNo

The content of the HTTP POST request.

params1=paramsValue1
TaskOption.HttpResponseMatchContentstringNo

The response to the HTTP request.

ok
TaskOption.HttpMethodstringNo

The HTTP request method. Valid values:

  • GET
  • POST
  • HEAD
Note This parameter must be specified when TaskType is set to HTTP.
GET
TaskOption.HttpNegativebooleanNo

The method to trigger an alert. The alert can be triggered based on whether the specified alert rule is included in the response body. Valid values:

  • true: If the HTTP response body includes the alert rule, an alert is triggered.
  • false: If the HTTP response does not include the alert rule, an alert is triggered.
Note This parameter must be specified when TaskType is set to HTTP.
true
TaskOption.HttpHeaderstringNo

The header of the HTTP request. Format: Parameter name:Parameter value. Separate multiple parameters with carriage return characters. Example:

params1:value1
params2:value2
token:testTokenValue
TaskOption.IntervalintegerNo

The interval at which detection requests are sent. Unit: seconds. Valid values: 15, 30, 60, 120, 300, 900, 1800, and 3600.

Note This parameter is available only for the CloudMonitor agent V3.5.1 or later.
60
AlertConfig.NotifyTypeintegerYes

The alert notification methods. Valid values:

0: Alert notifications are sent by using emails and DingTalk chatbots.

0
AlertConfig.StartTimeintegerNo

The beginning of the time range during which the alert rule is effective. Valid values: 0 to 23.

For example, if the AlertConfig.StartTime parameter is set to 0 and the AlertConfig.EndTime parameter is set to 22, the alert rule is effective from 00:00:00 to 22:00:00.

Note Alert notifications are sent based on the specified threshold only if the alert rule is effective.
0
AlertConfig.EndTimeintegerNo

The end of the time range during which the alert rule is effective. Valid values: 0 to 23.

For example, if the AlertConfig.StartTime parameter is set to 0 and the AlertConfig.EndTime parameter is set to 22, the alert rule is effective from 00:00:00 to 22:00:00.

Note Alert notifications are sent based on the specified threshold only if the alert rule is effective.
22
AlertConfig.SilenceTimeintegerNo

The mute period during which new alerts are not sent even if the trigger conditions are met. Unit: seconds. Default value: 86400. The default value indicates one day.

86400
AlertConfig.WebHookstringNo

The callback URL.

https://www.aliyun.com/webhook.json
AlertConfigEscalationListobject []Yes

None

MetricNamestringYes

The metric for which the alert feature is enabled. Valid values of N: 1 to 21. Valid values:

  • HttpStatus: HTTP status code
  • HttpLatency: HTTP response time
  • TelnetStatus: Telnet status code
  • TelnetLatency: Telnet response time
  • PingLostRate: Ping packet loss rate
HttpStatus
ValuestringNo

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

90
TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before an alert is triggered. Valid values of N: 1 to 21.

3
OperatorstringNo

The comparison operator that is used in the alert rule. Valid values of N: 1 to 21. Valid values:

  • >
  • >=
  • <
  • <=
  • =
>
AggregatestringNo

The method used to calculate the metric values that trigger alerts. Valid values of N: 1 to 21. Valid values:

  • HttpStatus: Value
  • HttpLatency: Average
  • TelnetStatus: Value
  • TelnetLatency: Average
  • PingLostRate: Average
Note The value Value indicates the original value and is used for metrics such as status codes. The value Average indicates the average value and is used for metrics such as the latency and packet loss rate.
Value
InstanceListarrayNo

The ECS instances that are monitored. Valid values of N: 1 to 21.

Note This parameter must be specified when TaskScope is set to GROUP_SPEC_INSTANCE.
stringNo

The ECS instances that are monitored. Valid values of N: 1 to 21.

Note This parameter must be specified when TaskScope is set to GROUP_SPEC_INSTANCE.
2
AlertConfigTargetListobject []No

The information about the resources for which alerts are triggered.

IdstringNo

The ID of the resource for which alerts are triggered.

1
ArnstringNo

The Alibaba Cloud Resource Name (ARN) of the resource. Format: acs:{Service name abbreviation}:{regionId}:{userId}:/{Resource type}/{Resource name}/message. Example: acs:mns:cn-hangzhou:120886317861****:/queues/test123/message. Fields:

  • {Service name abbreviation}: the abbreviation of the service name. Valid value: mns.

  • {userId}: the ID of the Alibaba Cloud account.

  • {regionId}: the region ID of the message queue or topic.

  • {Resource type}: the type of the resource that triggers the alert. Valid values:

    • queues
    • topics
  • {Resource name}: the resource name.

    • 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
LevelstringNo

The alert level. Valid values:

  • INFO
  • WARN
  • CRITICAL
["INFO", "WARN", "CRITICAL"]
JsonParamsstringNo

The parameters of the alert callback. The parameters are in the JSON format.

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

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

Response parameters

ParameterTypeDescriptionExample
object
Codestring

The status code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The error message.

The specified resource is not found.
RequestIdstring

The request ID.

ACBDBB40-DFB6-4F4C-8957-51FFB233969C
TaskIdlong

The ID of the availability monitoring task.

12345
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError message
400ParameterInvalidIllegal parameters.
403AccessForbiddenUser not authorized to operate on the specified resource.
404ResourceNotFound%s
409ResourceConflictConcurrent modification of resources.
409ResourceExistResources already exist.
412ResouceOverLimitThe task over limit
500InternalErrorThe request processing has failed due to some unknown error.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2022-08-05The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 409
    delete Error Codes: 412
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: AlertConfigTargetList
2022-03-22The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 409
    delete Error Codes: 500
    Added Error Codes: 412