• Elastic Load Balancing

elb
  1. Help Center
  2. Elastic Load Balancing
  3. API Reference
  4. Enhanced Load Balancer APIs
  5. Health Monitor (Health Check)
  6. Configuring a Health Check

Configuring a Health Check

Function

This API is used to configure a health check for a backend server group to check the status of backend servers. If the health check result is OFFLINE, backend servers are considered unhealthy. You need to check the server configuration.

URI

POST /v2.0/lbaas/healthmonitors

Constraints

The security group must allow access from the 100.125.0.0/16 network segment. Otherwise, the health check cannot be performed.

Request

  • Request parameters
    Table 1 Parameter description

    Parameter

    Type

    Mandatory

    Description

    healthmonitor

    Dict

    Yes

    Specifies the health check. For details, see Table 2.

    Table 2 healthmonitor field description

    Parameter

    Type

    Mandatory

    Description

    tenant_id

    String (255)

    No

    Specifies the ID of the project where the health check is performed.

    The value must be the same as the value of project_id in the token.

    name

    String (255)

    No

    Specifies the health check name.

    delay

    Int

    Yes

    Specifies the interval between health checks in the unit of second. The value ranges from 1 to 50.

    max_retries

    Int

    Yes

    Specifies the maximum number of retries. The value ranges from 1 to 10.

    pool_id

    uuid

    Yes

    Specifies the backend server group ID.

    Only one health check can be configured for each backend server group.

    admin_state_up

    Bool

    No

    Specifies the administrative status of the health check.

    The value can be true or false. The default value is true.

    • true: indicates that the health check function is enabled.
    • false: indicates that the health check function is disabled.

    timeout

    Int

    Yes

    Specifies the health check timeout duration in the unit of second. The value ranges from 1 to 50.

    NOTE:

    You are advised to set the value less than that of parameter delay.

    type

    String

    Yes

    Specifies the health check protocol.

    The value can be TCP, UDP_CONNECT, or HTTP.

    monitor_port

    Int

    No

    Specifies the health check port. The value ranges from 1 to 65535.

    The value is left blank by default, indicating that the port of the backend server is used as the health check port.

    domain_name

    String (100)

    No

    Specifies the domain name of the HTTP request during the health check.

    This parameter is valid when type is set to HTTP.

    The parameter value is left blank by default, indicating that the load balancer IP address is used as the destination address of HTTP requests.

    The parameter value can contain only digits, letters, hyphens (-), and periods (.) and must start with a digit or letter, for example, www.huaweitest.com.

    url_path

    String (255)

    No

    Specifies the HTTP request path for the health check. The default value is /, and the value must start with a slash (/).

    This parameter is valid when type is set to HTTP.

    An example value is /test.

    expected_codes

    String (19)

    No

    Specifies the expected HTTP response status code. The default value is 200.

    The value can be one of the following:

    A single value, such as 200

    A list of values, such as 200 and 202

    Value range, such as 200 to 204

    This parameter is valid when type is set to HTTP.
    NOTE:

    This parameter is reserved and has been not used.

    http_method

    String (16)

    No

    Specifies the HTTP request method. The default value is GET.

    The value can be GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, and PATCH.

    This parameter is valid when type is set to HTTP.

    NOTE:

    This parameter is reserved and has been not used.

  • Example request
    POST https://{Endpoint}/v2.0/lbaas/healthmonitors
    
    {
      "healthmonitor": {
        "admin_state_up": true,
        "pool_id": "bb44bffb-05d9-412c-9d9c-b189d9e14193",
        "domain_name": "www.test.com",
        "delay": 10,
        "max_retries": 10,
        "timeout": 10,
        "type": "HTTP"
      }
    }

Response

  • Response parameters
    Table 3 Parameter description

    Parameter

    Type

    Description

    healthmonitor

    Dict

    Specifies the health check. For details, see Table 4.

    Table 4 healthmonitor field description

    Parameter

    Type

    Description

    id

    Uuid

    Specifies the health check ID.

    tenant_id

    String (255)

    Specifies the ID of the project where the health check is performed.

    name

    String (255)

    Specifies the health check name.

    delay

    Int

    Specifies the interval between health checks in the unit of second. The value ranges from 1 to 50.

    max_retries

    Int

    Specifies the maximum number of retries. The value ranges from 1 to 10.

    pools

    List

    Lists the IDs of backend server groups associated with the health check.

    admin_state_up

    Bool

    Specifies the administrative status of the health check.

    The value can be true or false. The default value is true.

    • true: indicates that the health check function is enabled.
    • false: indicates that the health check function is disabled.

    timeout

    Int

    Specifies the health check timeout duration in the unit of second. The value ranges from 1 to 50.

    NOTE:

    You are advised to set the value less than that of parameter delay.

    type

    String

    Specifies the health check protocol.

    The value can be TCP, UDP_CONNECT, or HTTP.

    monitor_port

    Int

    Specifies the health check port. The value ranges from 1 to 65535.

    The value is left blank by default, indicating that the port of the backend server is used as the health check port.

    expected_codes

    String (19)

    Specifies the expected HTTP response status code. The default value is 200.

    The value can be one of the following:

    A single value, such as 200

    A list of values, such as 200 and 202

    Value range, such as 200 to 204

    This parameter is available only when type is set to HTTP.
    NOTE:

    This parameter is reserved and has been not used.

    domain_name

    String (100)

    Specifies the domain name of the HTTP request during the health check.

    This parameter is valid when type is set to HTTP.

    The parameter value is left blank by default, indicating that the load balancer IP address is used as the destination address of HTTP requests.

    The parameter value can contain only digits, letters, hyphens (-), and periods (.) and must start with a digit or letter, for example, www.huaweitest.com.

    url_path

    String (255)

    Specifies the HTTP request path for the health check. The default value is /, and the value must start with a slash (/).

    This parameter is valid when type is set to HTTP.

    An example value is /test.

    http_method

    String (16)

    Specifies the HTTP request method. The default value is GET.

    The value can be GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, and PATCH.

    This parameter is valid when type is set to HTTP.

    NOTE:

    This parameter is reserved and has been not used.

  • Example response
    {
      "healthmonitor": {
        "name": "",
        "admin_state_up": true,
        "tenant_id": "145483a5107745e9b3d80f956713e6a3",
        
        "domain_name": "www.test.com",
        "delay": 10,
        "expected_codes": "200",
        "max_retries": 10,
        "http_method": "GET",
        "timeout": 10,
        "pools": [
          {
            "id": "bb44bffb-05d9-412c-9d9c-b189d9e14193"
          }
        ],
        "url_path": "/",
        "type": "HTTP",
        "id": "2dca3867-98c5-4cde-8f2c-b89ae6bd7e36",
        "monitor_port": 112
      }
    }

Response Codes

For details, see HTTP Status Codes for Enhanced Load Balancers.