# Gateway Health Check

# Enable/Disable 'Health Check'

# URI

PUT /admin-api/gateway/{gateway_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" \
  http://{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" \
  http://{admin-site}/admin-api/gateway/1 \
  -d '{
      "enable_checker": false
  }'

# Response example

Status: 200 OK
{
    "status":0
}

# Fetch health check configurations

# URI

GET /admin-api/gateway/{gateway_id}

# Request example

# Shell

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