ALIYUN::ALB::HealthCheckTemplate类型用于创建健康检查模板。

语法

{
  "Type": "ALIYUN::ALB::HealthCheckTemplate",
  "Properties": {
    "HealthCheckInterval": Integer,
    "HealthCheckConnectPort": Integer,
    "HealthCheckCodes": List,
    "UnhealthyThreshold": Integer,
    "HealthCheckMethod": String,
    "HealthCheckPath": String,
    "HealthCheckTemplateName": String,
    "HealthCheckHost": String,
    "HealthyThreshold": Integer,
    "HealthCheckProtocol": String,
    "HealthCheckTimeout": Integer
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
HealthCheckInterval Integer 健康检查的时间间隔。 取值范围:1~50。

默认值:2。

单位:秒。
HealthCheckConnectPort Integer 健康检查使用的端口。 取值范围:0~65535。默认值:0,表示使用后端服务器的端口进行健康检查。
HealthCheckCodes List 健康检查正常的HTTP状态码。 取值:
  • 当HealthCheckProtocol取值为HTTP时,HealthCheckCodes可以选择http_2xx(默认值)、 http_3xx、http_4xx和http_5xx,多个状态码用半角逗号(,)分隔。
  • 当HealthCheckProtocol取值为gRPC时,HealthCheckCodes状态码范围:0~99,默认值:0。支持范围输入,最多支持20个范围值,多个范围值使用半角逗号(,)分隔。
说明 当HealthCheckProtocol取值为HTTP或gRPC时,该参数才生效。
UnhealthyThreshold Integer 健康检查连续失败多少次后,将后端服务器的健康检查状态由成功判定为失败。 取值范围:2~10。

默认值:3。

HealthCheckMethod String 健康检查方法。 取值:
  • HEAD(默认值):HTTP监听健康检查默认采用HEAD方法。
  • POST:gRPC监听健康检查默认采用POST方法。
  • GET:如果响应报文长度超过8 KB会被截断,但不会影响健康检查结果的判定。
说明 当HealthCheckProtocol取值为HTTP或gRPC时,该参数才生效。
HealthCheckPath String 用于健康检查的URL。 长度限制为1~80,支持使用字母、数字和短划线(-)、正斜线(/)、半角句号(.)、百分号(%)、半角问号(?)、井号(#)和and(&)以及扩展字符集_;~!()*[]@$^:',+。URL必须以正斜线(/)开头。
说明 当HealthCheckProtocol取值为HTTP时,该参数才生效。
HealthCheckTemplateName String 健康检查模板名称。 长度为2~128个英文或中文字符,必须以大小字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-)。
HealthCheckHost String 用于健康检查的域名。

默认值:$SERVER_IP。

长度限制为1~80个字符。需满足以下要求:
  • 可用字符为小写字母、数字、短划线(-)和半角句号(.)。
  • 至少包含一个半角句号(.),半角句号(.)不能出现在开头或结尾。
  • 最右侧的域标签只能包含字母,不能包含数字或短划线(-)。
  • 对于其它域标签,短划线(-)不能出现在开头或结尾。
说明 当HealthCheckProtocol取值为HTTP时,该参数才生效。
HealthyThreshold Integer 健康检查连续成功多少次后,将后端服务器的健康检查状态由失败判定为成功。 取值范围:2~10。

默认值:3。

HealthCheckProtocol String 健康检查采用的协议。 取值:
  • HTTP(默认值):通过发送HEAD或GET请求模拟浏览器的访问行为来检查服务器应用是否健康。
  • TCP:通过发送SYN握手报文来检测服务器端口是否存活。
  • gRPC:通过发送POST或GET请求来检查服务器应用是否健康。
HealthCheckTimeout Integer 接收来自运行状况检查响应需要等待的时间。 如果后端服务器在指定的时间内没有正确响应,则判定为健康检查失败。

取值范围:1~300。

默认值:5。

单位:秒。

说明 如果HealthCHeckTimeout的值小于HealthCheckInterval的值,则HealthCHeckTimeout无效,超时时间为HealthCheckInterval的值。

返回值

Fn::GetAtt

HealthCheckTemplateId:健康检查模板ID。

示例

  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "HealthCheckTemplateName": {
          "Type": "String",
          "Description": "The name of the health check template.\nThe name must be 2 to 128 characters in length, and can contain letters, digits, periods\n(.), underscores (_), and hyphens (-). The name must start with a letter."
        }
      },
      "Resources": {
        "HealthCheckTemplate": {
          "Type": "ALIYUN::ALB::HealthCheckTemplate",
          "Properties": {
            "HealthCheckTemplateName": {
              "Ref": "HealthCheckTemplateName"
            }
          }
        }
      },
      "Outputs": {
        "HealthCheckTemplateId": {
          "Description": "The ID of the health check template.",
          "Value": {
            "Fn::GetAtt": [
              "HealthCheckTemplate",
              "HealthCheckTemplateId"
            ]
          }
        }
      }
    }
  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      HealthCheckTemplateName:
        Type: String
        Description: |-
          The name of the health check template.
          The name must be 2 to 128 characters in length, and can contain letters, digits, periods
          (.), underscores (_), and hyphens (-). The name must start with a letter.
    Resources:
      HealthCheckTemplate:
        Type: ALIYUN::ALB::HealthCheckTemplate
        Properties:
          HealthCheckTemplateName:
            Ref: HealthCheckTemplateName
    Outputs:
      HealthCheckTemplateId:
        Description: The ID of the health check template.
        Value:
          Fn::GetAtt:
            - HealthCheckTemplate
            - HealthCheckTemplateId