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
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
}
]
}
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
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
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"
]
}
]
}
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"
}
}
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"
}