Health checks

A health check decides whether a Real Server is available. A server that fails its check is marked down and traffic goes to the rest; once it passes again it returns to service automatically.

Health checks

GET /healthchecks

Get Health Check Scripts

curl
curl -X GET "https://appliance.example.com/api/v1/healthchecks" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/healthchecks';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.get("https://appliance.example.com/api/v1/healthchecks", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/healthchecks', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Health check scripts",
  "data": [
    {
      "name": "Test",
      "description": "Test script",
      "services": [
        "layer-7"
      ],
      "builtin": true
    },
    {
      "name": "Test2",
      "description": "Test2 script",
      "services": [
        "layer-7",
        "layer-4"
      ],
      "builtin": false
    }
  ]
}

POST /healthchecks

Add a Health Check

This change is staged. Send PUT /services/apply to apply it.

Body parameters
name string Required
description string Required
script string Required
services array Required
parameters array of object

What this check’s script accepts, one entry per parameter. Declarations only: the values belong to whatever references the check. Omit it and any lb-param headers in the script are read instead.

Fields
name string Required

Becomes the --name=value flag, so letters and digits only.

label string
type integer | port | path | hostname | string
required boolean

Mutually exclusive with a default, which is what makes a parameter optional.

default string
curl
curl -X POST "https://appliance.example.com/api/v1/healthchecks" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "<name>",
  "description": "<description>",
  "script": "<script>",
  "services": [
    "<services>"
  ],
  "parameters": [
    {
      "name": "<name>",
      "label": "<label>",
      "type": "integer",
      "required": true,
      "default": "<default>"
    }
  ]
}'
PHP
<?php

$url = 'https://appliance.example.com/api/v1/healthchecks';
$headers = [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
];

$payload = [
    'name' => '<name>',
    'description' => '<description>',
    'script' => '<script>',
    'services' => [
        '<services>',
    ],
    'parameters' => [
        [
            'name' => '<name>',
            'label' => '<label>',
            'type' => 'integer',
            'required' => true,
            'default' => '<default>',
        ],
    ],
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}
payload = {
    "name": "<name>",
    "description": "<description>",
    "script": "<script>",
    "services": [
        "<services>"
    ],
    "parameters": [
        {
            "name": "<name>",
            "label": "<label>",
            "type": "integer",
            "required": true,
            "default": "<default>"
        }
    ]
}

response = requests.post("https://appliance.example.com/api/v1/healthchecks", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/healthchecks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "name": "<name>",
  "description": "<description>",
  "script": "<script>",
  "services": [
    "<services>"
  ],
  "parameters": [
    {
      "name": "<name>",
      "label": "<label>",
      "type": "integer",
      "required": true,
      "default": "<default>"
    }
  ]
}),
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Health check added successfully",
  "data": {
    "id": "5e1de37819dd5"
  }
}

Get the health check of a service

GET /healthchecks/service/{service}

Get HealthChecks

Path parameters
service string Required
curl
curl -X GET "https://appliance.example.com/api/v1/healthchecks/service/{service}" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/healthchecks/service/{service}';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.get("https://appliance.example.com/api/v1/healthchecks/service/{service}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/healthchecks/service/{service}', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Health check scripts",
  "data": [
    {
      "name": "Test2",
      "description": "Test2 script",
      "services": [
        "layer-7",
        "layer-4"
      ]
    }
  ]
}

By ID

GET /healthchecks/{id}

Get HealthChecks

Path parameters
id string Required
curl
curl -X GET "https://appliance.example.com/api/v1/healthchecks/{id}" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/healthchecks/{id}';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.get("https://appliance.example.com/api/v1/healthchecks/{id}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/healthchecks/{id}', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Health check",
  "data": [
    {
      "name": "Test2",
      "description": "Test2 script",
      "script": "testcheck2.sh",
      "services": [
        "layer-7",
        "layer-4"
      ]
    }
  ]
}

PUT /healthchecks/{id}

Edit a Health Check

This change is staged. Send PUT /services/apply to apply it.

Path parameters
id string Required

The id of the healthcheck.

Body parameters
name string Required
description string Required
script string Required
services array Required
parameters array of object

What this check’s script accepts, one entry per parameter. Declarations only: the values belong to whatever references the check. Omit it and any lb-param headers in the script are read instead.

Fields
name string Required

Becomes the --name=value flag, so letters and digits only.

label string
type integer | port | path | hostname | string
required boolean

Mutually exclusive with a default, which is what makes a parameter optional.

default string
curl
curl -X PUT "https://appliance.example.com/api/v1/healthchecks/{id}" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "<name>",
  "description": "<description>",
  "script": "<script>",
  "services": [
    "<services>"
  ],
  "parameters": [
    {
      "name": "<name>",
      "label": "<label>",
      "type": "integer",
      "required": true,
      "default": "<default>"
    }
  ]
}'
PHP
<?php

$url = 'https://appliance.example.com/api/v1/healthchecks/{id}';
$headers = [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
];

$payload = [
    'name' => '<name>',
    'description' => '<description>',
    'script' => '<script>',
    'services' => [
        '<services>',
    ],
    'parameters' => [
        [
            'name' => '<name>',
            'label' => '<label>',
            'type' => 'integer',
            'required' => true,
            'default' => '<default>',
        ],
    ],
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}
payload = {
    "name": "<name>",
    "description": "<description>",
    "script": "<script>",
    "services": [
        "<services>"
    ],
    "parameters": [
        {
            "name": "<name>",
            "label": "<label>",
            "type": "integer",
            "required": true,
            "default": "<default>"
        }
    ]
}

response = requests.put("https://appliance.example.com/api/v1/healthchecks/{id}", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/healthchecks/{id}', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "name": "<name>",
  "description": "<description>",
  "script": "<script>",
  "services": [
    "<services>"
  ],
  "parameters": [
    {
      "name": "<name>",
      "label": "<label>",
      "type": "integer",
      "required": true,
      "default": "<default>"
    }
  ]
}),
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Health check updated successfully",
  "data": {
    "id": "5e1de37819dd5"
  }
}

DELETE /healthchecks/{id}

Delete HealthChecks

This change is staged. Send PUT /services/apply to apply it.

Path parameters
id string Required
curl
curl -X DELETE "https://appliance.example.com/api/v1/healthchecks/{id}" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/healthchecks/{id}';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.delete("https://appliance.example.com/api/v1/healthchecks/{id}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/healthchecks/{id}', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Health check deleted successfully"
}