From 556e8c67c5a489777c8ccfbcde0217926ee3c091 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C4=93teris=20Caune?=
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
+curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
Example Response
-{
+{
"checks": [
{
"name": "Filesystem Backup",
@@ -151,7 +151,7 @@ specified value.
When using the read-only API key, the following fields are omitted:
ping_url
, update_url
, pause_url
, channels
. An extra unique_key
field
is added which can be used to GET
a check in place of the UUID
. The unique_key
identifier is stable across API calls. Example:
-{
+{
"checks": [
{
"name": "Filesystem Backup",
@@ -203,12 +203,12 @@ using the read-only API key) as an identifier.
The specified check does not exist.
Example Request
-curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/<uuid>
+curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/<uuid>
Example Response
-{
+{
"name": "Database Backup",
"tags": "production db",
"desc": "Runs ~/db-backup.sh",
@@ -235,7 +235,7 @@ added. This identifier is stable across API calls.
Note: the ping_url
, update_url
and pause_url
fields, although omitted, are not
really secret. The client already knows the check's unique UUID and so can easily
construct these URLs by itself.
-{
+{
"name": "Database Backup",
"tags": "production db",
"desc": "Runs ~/db-backup.sh",
@@ -361,20 +361,20 @@ field values.
the limit is 20 checks per account.
Example Request
-curl SITE_ROOT/api/v1/checks/ \
+curl SITE_ROOT/api/v1/checks/ \
--header "X-Api-Key: your-api-key" \
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
Or, alternatively:
-curl SITE_ROOT/api/v1/checks/ \
+curl SITE_ROOT/api/v1/checks/ \
--data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
Example Response
-{
+{
"channels": "",
"desc": "",
"grace": 60,
@@ -485,20 +485,20 @@ field values.
The specified check does not exist.
Example Request
-curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
+curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
--header "X-Api-Key: your-api-key" \
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
Or, alternatively:
-curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
+curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
--data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
Example Response
-{
+{
"channels": "",
"desc": "",
"grace": 60,
@@ -534,7 +534,7 @@ state. You can resume monitoring of the check by pinging it.
The specified check does not exist.
Example Request
-curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
+curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
--request POST --header "X-Api-Key: your-api-key" --data ""
@@ -543,7 +543,7 @@ state. You can resume monitoring of the check by pinging it.
even though the request body is empty. For HTTP POST requests, the Content-Length
header is sometimes required by some network proxies and web servers.
Example Response
-{
+{
"channels": "",
"desc": "",
"grace": 60,
@@ -579,13 +579,13 @@ check that was just deleted.
The specified check does not exist.
Example Request
-curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
+curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
--request DELETE --header "X-Api-Key: your-api-key"
Example Response
-{
+{
"channels": "",
"desc": "",
"grace": 60,
@@ -622,13 +622,13 @@ number of returned pings depends on account's billing plan: 100 for free account
The specified check does not exist.
Example Request
-curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ \
+curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ \
--header "X-Api-Key: your-api-key"
Example Response
-{
+{
"pings": [
{
"type": "success",
@@ -713,13 +713,13 @@ number of returned pings depends on account's billing plan: 100 for free account
The specified check does not exist.
Example Request
-curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ \
+curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ \
--header "X-Api-Key: your-api-key"
Example Response
-[
+[
{
"timestamp": "2020-03-23T10:18:23+00:00",
"up": 1
@@ -747,12 +747,12 @@ number of returned pings depends on account's billing plan: 100 for free account
The API key is either missing or invalid.
Example Request
-curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
+curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
Example Response
-{
+{
"channels": [
{
"id": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941",
diff --git a/templates/docs/attaching_logs.html b/templates/docs/attaching_logs.html
index 75e8876b..3ed16b33 100644
--- a/templates/docs/attaching_logs.html
+++ b/templates/docs/attaching_logs.html
@@ -6,7 +6,7 @@ the request body, so you can inspect it later.
Logging Command Output
In this example, we run certbot renew
, capture its output, and submit
the captured output to SITE_NAME:
-#!/bin/sh
+#!/bin/sh
m=$(/usr/bin/certbot renew 2>&1)
curl -fsS --retry 3 --data-raw "$m" PING_URL
@@ -16,7 +16,7 @@ curl -fsS --retry 3 --data-raw "In Combination with the /fail
Endpoint
We can extend the previous example and signal either success or failure
depending on the exit code:
-#!/bin/sh
+#!/bin/sh
url=PING_URL
@@ -30,5 +30,5 @@ curl -fsS --retry 3 --data-raw "All in One Line
Finally, all of the above can be packaged in a single line. The one-line
version can be put directly in crontab, without using a wrapper script.
-m=$(/usr/bin/certbot renew 2>&1); curl -fsS --data-raw "$m" "PING_URL$([ $? -ne 0 ] && echo -n /fail)"
+m=$(/usr/bin/certbot renew 2>&1); curl -fsS --data-raw "$m" "PING_URL$([ $? -ne 0 ] && echo -n /fail)"
\ No newline at end of file
diff --git a/templates/docs/bash.html b/templates/docs/bash.html
index aceecc5d..73664b37 100644
--- a/templates/docs/bash.html
+++ b/templates/docs/bash.html
@@ -4,7 +4,7 @@ have to do is make a HTTP request at an appropriate place in the script.
curl and
wget
are two common command line HTTP clients you can use.
-# Sends a HTTP GET request with curl:
+# Sends a HTTP GET request with curl:
curl -m 10 --retry 5 PING_URL
# Silent version (no stdout/stderr output unless curl hits an error):
@@ -38,7 +38,7 @@ signal a failure. The following example:
if the certbot command is successful (exit code 0), sends HTTP GET to PING_URL
otherwise, sends HTTP GET to PING_URL/fail
-#!/bin/sh
+#!/bin/sh
# Payload here:
/usr/bin/certbot renew
@@ -52,7 +52,7 @@ curl -m 10 --retry 5 #!/bin/sh
+#!/bin/sh
m=$(/usr/bin/certbot renew 2>&1)
curl -fsS -m 10 --retry 5 --data-raw "$m" PING_URL
@@ -64,7 +64,7 @@ curl -fsS -m 10 --retry 5 --data-r
(if it does not already exist) and to retrieve its ping URL.
Using this technique, you can write services that automatically
register with SITE_NAME the first time they run.
-#!/bin/bash
+#!/bin/bash
API_KEY=your-api-key-here
diff --git a/templates/docs/cloning_checks.html b/templates/docs/cloning_checks.html
index 8206e999..fd64968a 100644
--- a/templates/docs/cloning_checks.html
+++ b/templates/docs/cloning_checks.html
@@ -16,7 +16,7 @@ an existing deployment in a new region. The SITE_NAME web interface does
not have a function to clone an entire project, but this can be done relatively
easily using the Management API calls. Below is an example using Python
and the requests library:
-import requests
+import requests
API_URL = "SITE_ROOT/api/v1/checks/"
SOURCE_PROJECT_READONLY_KEY = "..."
diff --git a/templates/docs/configuring_prometheus.html b/templates/docs/configuring_prometheus.html
index c21a858c..609c2c21 100644
--- a/templates/docs/configuring_prometheus.html
+++ b/templates/docs/configuring_prometheus.html
@@ -7,7 +7,7 @@ the Prometheus endpoint:
Update the prometheus.yml
You can copy the Prometheus endpoint URL and add it to the Prometheus configuration:
- - job_name: "healthchecks"
+ - job_name: "healthchecks"
scrape_interval: 60s
scheme: SITE_SCHEME
metrics_path: /projects/45sd78-eeee-dddd-8888-b25a9887ecfd/metrics/NXyGzks4s8xcF1J-wzoaioyoqXIANGD0
diff --git a/templates/docs/csharp.html b/templates/docs/csharp.html
index 7982903c..2ed82063 100644
--- a/templates/docs/csharp.html
+++ b/templates/docs/csharp.html
@@ -1,6 +1,6 @@
C#
Below is an example of making a HTTP request to SITE_NAME from C#.
-using (var client = new System.Net.WebClient())
+using (var client = new System.Net.WebClient())
{
client.DownloadString("PING_URL");
}
diff --git a/templates/docs/http_api.html b/templates/docs/http_api.html
index abb1c8a8..eae246c9 100644
--- a/templates/docs/http_api.html
+++ b/templates/docs/http_api.html
@@ -15,7 +15,7 @@ If the request body looks like a UTF-8 string, SITE_NAME stores the request body
Successful responses will have the "200 OK" HTTP response status code and a short
and simple string "OK" in the response body.
Send a "success" Signal
-HEAD|GET|POST PING_ENDPOINT{uuid}
+HEAD|GET|POST PING_ENDPOINT{uuid}
@@ -23,12 +23,12 @@ and simple string "OK" in the response body.
continuously running processes, is still running and healthy). The uuid
parameter
is unique for each check.
Example
-GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278 HTTP/1.0
+GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278 HTTP/1.0
Host: hc-ping.com
-HTTP/1.1 200 OK
+HTTP/1.1 200 OK
Server: nginx
Date: Wed, 29 Jan 2020 09:58:23 GMT
Content-Type: text/plain; charset=utf-8
@@ -41,19 +41,19 @@ OK
Send a "fail" Signal
-HEAD|GET|POST PING_ENDPOINT{uuid}/fail
+HEAD|GET|POST PING_ENDPOINT{uuid}/fail
Signals to SITE_NAME that the job has failed. Actively signalling a failure
minimizes the delay from your monitored service failing to you receiving an alert.
Example
-GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/fail HTTP/1.0
+GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/fail HTTP/1.0
Host: hc-ping.com
-HTTP/1.1 200 OK
+HTTP/1.1 200 OK
Server: nginx
Date: Wed, 29 Jan 2020 09:58:23 GMT
Content-Type: text/plain; charset=utf-8
@@ -66,7 +66,7 @@ OK
Send a "start" Signal
-HEAD|GET|POST PING_ENDPOINT{uuid}/start
+HEAD|GET|POST PING_ENDPOINT{uuid}/start
@@ -77,12 +77,12 @@ optional but enables a few extra features:
SITE_NAME will detect if the job runs longer than its configured grace time
Example
-GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/start HTTP/1.0
+GET /5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278/start HTTP/1.0
Host: hc-ping.com
-HTTP/1.1 200 OK
+HTTP/1.1 200 OK
Server: nginx
Date: Wed, 29 Jan 2020 09:58:23 GMT
Content-Type: text/plain; charset=utf-8
diff --git a/templates/docs/javascript.html b/templates/docs/javascript.html
index 4e0e1c3c..012b64ae 100644
--- a/templates/docs/javascript.html
+++ b/templates/docs/javascript.html
@@ -1,13 +1,13 @@
Javascript
Below is an example of making a HTTP request to SITE_NAME from Node.js.
-var https = require('https');
+var https = require('https');
https.get("PING_URL");
You can also send pings from a browser environment. SITE_NAME sets the
Access-Control-Allow-Origin:*
CORS header, so cross-domain AJAX requests work.
-var xhr = new XMLHttpRequest();
+var xhr = new XMLHttpRequest();
xhr.open('GET', 'PING_URL', true);
xhr.send(null);
\ No newline at end of file
diff --git a/templates/docs/measuring_script_run_time.html b/templates/docs/measuring_script_run_time.html
index 5217d455..85eb8c7a 100644
--- a/templates/docs/measuring_script_run_time.html
+++ b/templates/docs/measuring_script_run_time.html
@@ -7,7 +7,7 @@
Signalling a start kicks off a separate timer: the job now must signal a
success within its configured "Grace Time", or it will get marked as "down".
Below is a code example in Python:
-import requests
+import requests
URL = "PING_URL"
diff --git a/templates/docs/monitoring_cron_jobs.html b/templates/docs/monitoring_cron_jobs.html
index 59418976..72e5bbd7 100644
--- a/templates/docs/monitoring_cron_jobs.html
+++ b/templates/docs/monitoring_cron_jobs.html
@@ -3,7 +3,7 @@
update your cron job command to send a HTTP request to SITE_NAME
after a job completes.
Let's look at an example:
-$ crontab -l
+$ crontab -l
# m h dom mon dow command
8 6 * * * /home/user/backup.sh
@@ -40,7 +40,7 @@ increasingly important as you add more checks to your account.
Finally, edit your cron job definition and append a curl or wget call
after the command:
-$ crontab -e
+$ crontab -e
# m h dom mon dow command
8 6 * * * /home/user/backup.sh && curl -fsS --retry 5 -o /dev/null PING_URL
@@ -81,7 +81,7 @@ Transient error is a timeout or an HTTP 5xx response code.
Looking up Your Machine's Time Zone
On modern GNU/Linux systems, you can look up the time zone using the
timedatectl status
command and looking for "Time zone" in its output:
-$ timedatectl status
+$ timedatectl status
Local time: C 2020-01-23 12:35:50 EET
Universal time: C 2020-01-23 10:35:50 UTC
diff --git a/templates/docs/php.html b/templates/docs/php.html
index e24112da..4b70bbfe 100644
--- a/templates/docs/php.html
+++ b/templates/docs/php.html
@@ -1,18 +1,18 @@
PHP
Below is an example of making a HTTP request to SITE_NAME from PHP.
-file_get_contents('PING_URL');
+file_get_contents('PING_URL');
If you would like to setup timeout and retry options, as discussed in the
reliability tips section, there is a
curl package available that lets you do that easily:
-use Curl\Curl;
+use Curl\Curl;
-$curl = new Curl();
-$curl->setRetry(20);
-$curl->setTimeout(5);
-$curl->get('PING_URL');
+$curl = new Curl();
+$curl->setRetry(20);
+$curl->setTimeout(5);
+$curl->get('PING_URL');
diff --git a/templates/docs/powershell.html b/templates/docs/powershell.html
index 65156c33..5961d403 100644
--- a/templates/docs/powershell.html
+++ b/templates/docs/powershell.html
@@ -5,19 +5,19 @@
Here is a simple PowerShell script that pings SITE_NAME. When scheduled to
run with Task Scheduler, it will essentially just send regular "I'm alive" messages.
You can of course extend it to do more things.
-# inside a PowerShell script:
-Invoke-RestMethod PING_URL
+# inside a PowerShell script:
+Invoke-RestMethod PING_URL
Save the above to e.g. C:\Scripts\healthchecks.ps1
.
Then use the following command in a Scheduled Task to run the script:
-powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
+powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
In simple cases, you can also pass the script to PowerShell directly,
using the "-command" argument:
-# Without an underlying script, passing the command to PowerShell directly:
-powershell.exe -command &{Invoke-RestMethod PING_URL}
+# Without an underlying script, passing the command to PowerShell directly:
+powershell.exe -command &{Invoke-RestMethod PING_URL}
\ No newline at end of file
diff --git a/templates/docs/powershell.md b/templates/docs/powershell.md
index 84d51ee8..c8deed06 100644
--- a/templates/docs/powershell.md
+++ b/templates/docs/powershell.md
@@ -8,7 +8,7 @@ Here is a simple PowerShell script that pings SITE_NAME. When scheduled to
run with Task Scheduler, it will essentially just send regular "I'm alive" messages.
You can of course extend it to do more things.
-```bash
+```powershell
# inside a PowerShell script:
Invoke-RestMethod PING_URL
```
@@ -16,14 +16,14 @@ Invoke-RestMethod PING_URL
Save the above to e.g. `C:\Scripts\healthchecks.ps1`.
Then use the following command in a Scheduled Task to run the script:
-```bash
+```bat
powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
```
In simple cases, you can also pass the script to PowerShell directly,
using the "-command" argument:
-```bash
+```bat
# Without an underlying script, passing the command to PowerShell directly:
powershell.exe -command &{Invoke-RestMethod PING_URL}
```
diff --git a/templates/docs/python.html b/templates/docs/python.html
index 65e37376..23031cfb 100644
--- a/templates/docs/python.html
+++ b/templates/docs/python.html
@@ -1,6 +1,6 @@
Python
If you are already using the requests library, it is convenient to also use it here:
-import requests
+import requests
try:
requests.get("PING_URL", timeout=10)
@@ -11,7 +11,7 @@
Otherwise, you can use the urllib module from Python 3 standard libary:
-import socket
+import socket
import urllib.request
try:
@@ -23,7 +23,7 @@
You can include additional diagnostic information in the in the request body (for POST requests):
-# Passing diagnostic information in the POST body:
+# Passing diagnostic information in the POST body:
import requests
requests.post("PING_URL", data="temperature=-7")
\ No newline at end of file
diff --git a/templates/docs/reliability_tips.html b/templates/docs/reliability_tips.html
index 76cc9eaf..efa42cd3 100644
--- a/templates/docs/reliability_tips.html
+++ b/templates/docs/reliability_tips.html
@@ -11,7 +11,7 @@ running worker process which pings SITE_NAME after each completed item. A stuck
request would block the whole process, so it is important to guard against.
Specifying the timeout depends on the tool you use. curl, for example, has the
--max-time
(shorthand: -m
) parameter:
-# Send a HTTP, 10 second timeout:
+# Send a HTTP, 10 second timeout:
curl -m 10 PING_URL
@@ -21,7 +21,7 @@ curl -m 10 PING_URL
client to retry failed requests several times.
Specifying the retry policy depends on the tool you use. curl, for example, has the
--retry
parameter:
-# Retry up to 5 times, uses an increasing delay between each retry (1s, 2s, 4s, 8s, ...)
+