Register User
To start using API Health Check, you first need to register a user account.
curl -X 'POST' \
'https://apihealthcheck.io/users' \
-d '{
"email": "<your email>",
"password": "<your password>"
}'
Replace <your email>
and <your password>
with your actual email and desired password. This command will create a new user account for you and will return a response body like:
{
"id": "3d6184e1-b74b-461c-9752-eedef2d8a5b4",
"email": "<your email>",
"api_key": "504d03245b65735c0ac8f51261b9ecc3712e1fc899a6c6f294fcca325c35f275",
"default_org": "8346284e-b74b-461c-9752-eedef2d8a5b4",
"session_token": "s.504d03245b65735c0ac8f51261b9ecc3712e1fc899a6c6f294fcca325c35f275",
"expire_time": "2024-05-07T23:25:39+0000",
"update_time": "2024-05-07T22:25:39+0000",
"create_time": "2024-05-06T22:25:39+0000"
}
You can use the api_key
and session_token
in subsequent calls within the Authorization
header. Keep in mind your email will need to be verified before creating multi-regional health checks.
Creating multi-regional health check
Once registered, you can set up a multi-region health check for your API. The following curl
command shows how to do this:
curl -X 'POST' \
'https://apihealthcheck.io/orgs/<default_org>/healthchecks' \
-H 'Authorization: <api_key or session_token>' \
-d '{
"name": "apihealthcheck.io API",
"url": "https://apihealthcheck.io/health",
"expression": "response.status_code != 200",
"frequency_seconds": 60,
"regions": [
"us-central1",
"europe-west1",
"asia-northeast1"
],
"filters": [
{
"name": "service down",
"expression": "metadata.down == true"
},
{
"name": "average 5 min latency over 5 seconds",
"expression": "metadata.latency.five_minute_ms > 5000"
}
],
"alerts": [
{
"name": "email alert to admin@example.com",
"type": "email",
"config": {
"recipient": "admin@example.com"
}
}
]
}'
This command sets up a health check for the apihealthcheck.io
API. It monitors the API from three regions: us-central1
, europe-west1
, and asia-northeast1
. The health check will run every 60 seconds and includes a filter to trigger an alert if the service is down or the average latency over 5 minutes exceeds 5 seconds. An email alert will be sent to admin@example.com
if any triggers are detected.
Get Health checks logs
Give the health checks a couple minutes to start up and then you can check out the health checks logs. These are the logs you will write your health check and filter expressions against.
curl -X 'GET' \
'https://apihealthcheck.io/orgs/<default_org>/healthchecks/<healthcheck_id>/logs?region=us-central1&hour_time_range=1' \
-H 'Authorization: <session_token or api_key>'
The response will contain informations about the health checks request and response, metadata associated with the health check and if the expressions are failing for both health checks and filters.
{
"data": [
{
"filter_logs": [
{
"filter_id": "389839cc-f0ef-49c5-8e7e-078183250673",
"filtered": false,
"expression_error": "",
"create_time": "2024-07-10T01:32:25.125912Z"
}
],
"metadata": {
"consecutive_fails": 0,
"create_time": "2024-07-10T01:32:26Z",
"down": false,
"down_time_seconds": 0,
"expression_error": "",
"latency": {
"one_minute_ms": 10,
"two_minute_ms": 9,
"three_minute_ms": 9,
"five_minute_ms": 9,
"ten_minute_ms": 10
},
"region": "us-central1"
},
"request": {
"url": "https://apihealthcheck.io/health"
},
"response": {
"body": "{\"message\":\"success\",\"status_code\":200}\n",
"headers": {
"Alt-Svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
"Content-Length": "40",
"Content-Type": "application/json",
"Date": "Wed, 10 Jul 2024 01:32:25 GMT",
"Server": "Google Frontend",
"X-Cloud-Trace-Context": "b02ad2a683eedc2a1fcdad497a8bc7ad"
},
"json": {
"message": "success",
"status_code": 200
},
"latency_ms": 10,
"status_code": 200
}
}
]
}
Swagger Documentation
For detailed API documentation, please visit the Swagger Docs.
Contact Us
ApiHealthCheck.io has just been released and still is currently in early release.
If you run into any issues, have any questions or general feedback please reach out to apihealthcheckio@gmail.com