Gateway Node Health Check

OpenResty Edge support configure Gateway Node health check on both gateway cluster level or partition level. They have the similar usage, just on different level. OpenResty Edge will use partition level configuration by default (when gateway cluster level health check not configured).

Enable/Disable ‘Health Check’ on gateway cluster level

URI

PUT /admin-api/gateway/{gateway_id}

JSON body

  • enable_checker

    type: bool

    required: no

    description: enable health checker or not. It means use the partition level health check configuration when the enable_checker is NULL or no existing.

  • checker

    type: hash

    required: no

    description: health checker options.

  • type

    type: string

    required: yes

    description: can be “TCP”, “HTTP” or “HTTPS”. The edge-admin will try to connect to the edge-node using TCP protocol when type is tcp. The edge-admin send HTTP request to edge-node when type is http. The edge-admin send HTTPS request to edge-node when type is https.

  • port

    type: int

    required: yes

    description: the port on the edge-node to accept health checker request.

  • timeout

    type: number (seconds)

    required: yes

    description: timeout for TCP connect and socket read/write.

  • rise

    type: int

    required: yes

    description: After the specified times of failure health checks, consider the gateway node as offline.

  • fall

    type: int

    required: yes

    description: After the specified times of successful health checks, consider the gateway node as online.

  • interval

    type: number

    required: yes

    description: the interval for each health check.

  • interval_unit

    type: string

    required: yes

    description: the interval unit for each health check, can be sec, min or hour.

  • http_ver

    type: string

    required: yes when type is http or https

    description: can be ‘1.0’ or ‘1.1’.

  • http_req_host

    type: string

    required: yes when type is http or https

    description: The host field of HTTP request header.

  • http_req_uri

    type: string

    required: yes when type is http or https

    description: The HTTP request URI.

  • valid_statuses

    type: array of int

    required: no

    description: The item of the array can be 200, 301 or 302.

  • resp_body_match

    type: string

    required: no

    description: the response body should contains the specified string literal.

  • user_agent

    type: string

    required: no

    description: The user-agent field of HTTP request header.

Request example

Shell

Enable health check:

curl \
  -X PUT \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/gateway/1 \
  -d '{
      "enable_checker": true,
      "checker": {
          "type": "http",
          "port": 80,
          "timeout": 3,
          "rise": 2,
          "fall": 3,
          "interval": 10,
          "interval_unit": "sec",
          "http_req_host": "test.com",
          "http_req_uri": "/health-checker"
      }
  }'

Disable health check:

curl \
  -X PUT \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/gateway/1 \
  -d '{
      "enable_checker": false
  }'

Response example

Status: 200 OK
{
    "status":0
}

Fetch gateway cluster level health check configurations

URI

GET /admin-api/gateway/{gateway_id}

Request example

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://admin-site/admin-api/gateway/1

Enable/Disable ‘Health Check’ on partition level

URI

PUT /admin-api/partitions/{partition_id}

JSON body

  • enable_checker

    type: bool

    required: no

    description: enable health checker or not.

  • checker

    type: hash

    required: no

    description: health checker options.

  • type

    type: string

    required: yes

    description: can be “TCP”, “HTTP” or “HTTPS”. The edge-admin will try to connect to the edge-node using TCP protocol when type is tcp. The edge-admin send HTTP request to edge-node when type is http. The edge-admin send HTTPS request to edge-node when type is https.

  • port

    type: int

    required: yes

    description: the port on the edge-node to accept health checker request.

  • timeout

    type: number (seconds)

    required: yes

    description: timeout for TCP connect and socket read/write.

  • rise

    type: int

    required: yes

    description: After the specified times of failure health checks, consider the gateway node as offline.

  • fall

    type: int

    required: yes

    description: After the specified times of successful health checks, consider the gateway node as online.

  • interval

    type: number

    required: yes

    description: the interval for each health check.

  • interval_unit

    type: string

    required: yes

    description: the interval unit for each health check, can be sec, min or hour.

  • http_ver

    type: string

    required: yes when type is http or https

    description: can be ‘1.0’ or ‘1.1’.

  • http_req_host

    type: string

    required: yes when type is http or https

    description: The host field of HTTP request header.

  • http_req_uri

    type: string

    required: yes when type is http or https

    description: The HTTP request URI.

  • valid_statuses

    type: array of int

    required: no

    description: The item of the array can be 200, 301 or 302.

  • resp_body_match

    type: string

    required: no

    description: the response body should contains the specified string literal.

  • user_agent

    type: string

    required: no

    description: The user-agent field of HTTP request header.

Request example

Shell

Enable health check:

curl \
  -X PUT \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/partitions/1 \
  -d '{
      "enable_checker": true,
      "checker": {
          "type": "http",
          "port": 80,
          "timeout": 3,
          "rise": 2,
          "fall": 3,
          "interval": 10,
          "interval_unit": "sec",
          "http_req_host": "test.com",
          "http_req_uri": "/health-checker"
      }
  }'

Disable health check:

curl \
  -X PUT \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/partitions/1 \
  -d '{
      "enable_checker": false
  }'

Response example

Status: 200 OK
{
    "status":0
}

Fetch partition level health check configurations

URI

GET /admin-api/partitions/{partition_id}

Request example

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://admin-site/admin-api/partitions/1