Skip to content

Update Heartbeat check overview page #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 6, 2025
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
240 changes: 70 additions & 170 deletions site/content/docs/heartbeat-checks/_index.md

Large diffs are not rendered by default.

228 changes: 228 additions & 0 deletions site/content/docs/heartbeat-checks/ping-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
---
title: Ping examples - Checkly Docs
displayTitle: Ping examples
navTitle: Ping examples
weight: 15
menu:
resources:
parent: "Heartbeat checks"

---

Here you can find examples on how to ping a Heartbeat check.

Most examples use `GET` as the request method, but Heartbeat checks also accept `POST` requests. Your check won't record `PUT` or `DELETE` requests as pings, and the endpoint will return an error.

## Shell
Adding a ping to a shell script only requires a single line.

This is an example using [curl](https://curl.se/). We recommend using the `-m` and `--retry` options to specify timeout and retries to reduce the risk of false alerts or blocking the script.

{{< tabs "Shell" >}}
{{< tab "Get" >}}
```BASH {title="run_backup.sh"}
curl -m 5 --retry 3 https://ping.checklyhq.com/f0e0b1d3-665d-49d0-8bf0-3e6504c3d372
```
{{< /tab >}}
{{< tab "POST" >}}
```BASH {title="run_backup.sh"}
curl -X "POST" -m 5 --retry 3 https://ping.checklyhq.com/f0e0b1d3-665d-49d0-8bf0-3e6504c3d372
```
{{< /tab >}}
{{< /tabs >}}

This is a similar example with [wget](https://www.gnu.org/software/wget/). Use the options `-t` for retries and `-T` for timeout.

```BASH {title="run_backup.sh"}
wget -T 5 -t 3 https://ping.checklyhq.com/87c05896-3b7d-49ae-83ff-5e81323a54c4
```

You can use curl for [Render cron jobs](https://render.com/docs/cronjobs) and the [Heroku Scheduler](https://devcenter.heroku.com/articles/scheduler):

```BASH
run_backup.sh && curl -m 5 --retry 3 https://ping.checklyhq.com/f0e0b1d3-665d-49d0-8bf0-3e6504c3d372
```

## Kubernetes CronJob
Here is an example of how to add the curl command to a Kubernetes CronJob.

```YAML {title="my-scheduled-job.yaml"}
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: curl
image: docker.io/curlimages/curl:latest
imagePullPolicy: IfNotPresent
command:
- sh
- -c
args:
- 'curl -m 5 --retry 3 https://ping.checklyhq.com/f0e0b1d3-665d-49d0-8bf0-3e6504c3d372;'
restartPolicy: OnFailure
```

## Node.js

You can use any HTTP request library (`https`, `axios`, etc.) to ping your Heartbeat check.

This is an example with the built-in [https.get](https://nodejs.org/api/https.html#httpsgeturl-options-callback) package:

{{< tabs "https.get" >}}
{{< tab "Typescript" >}}
```ts {title="my-scheduled-job.ts"}
import https from "https";

// Sample URL
const url = "https://ping.checklyhq.com/87c05896-3b7d-49ae-83ff-5e81323a54c4";

const options = {
timeout: 5000,
};

https.get(url, options, (res) => {
console.log("statusCode:", res.statusCode);

res.on('data', (data) => {
console.log("responseBody:", data);
});
});
```
{{< /tab >}}
{{< tab "Javascript" >}}
```js {title="my-scheduled-job.js"}
const https = require("https");

// Sample URL
const url = "https://ping.checklyhq.com/87c05896-3b7d-49ae-83ff-5e81323a54c4";

const options = {
timeout: 5000,
};

https.get(url, options, (res) => {
console.log("statusCode:", res.statusCode);

res.on('data', (data) => {
console.log("responseBody:", data);
});
});
```
{{< /tab >}}
{{< /tabs >}}

You can also use [Axios](https://axios-http.com/):

{{< tabs "axios" >}}
{{< tab "TypeScript" >}}
```ts {title="my-scheduled-job.ts"}
import axios from 'axios'

axios.get('https://ping.checklyhq.com/87c05896-3b7d-49ae-83ff-5e81323a54c4')
.then(resp => {
console.log(resp.data);
})

```
{{< /tab >}}
{{< tab "JavaScript" >}}
```js {title="my-scheduled-job.js"}
const axios = require('axios');

axios.get('https://ping.checklyhq.com/87c05896-3b7d-49ae-83ff-5e81323a54c4')
.then(resp => {
console.log(resp.data);
})
```
{{< /tab >}}
{{< /tabs >}}

## Vercel cron jobs

You can monitor your [Vercel cron jobs](https://vercel.com/docs/cron-jobs) with Heartbeat checks. At the end of your cron job, make an HTTP `GET` or `POST` request to your ping URL. For example, using `fetch()`:

{{< tabs "Vercel example" >}}
{{< tab "Next.js (App Router)" >}}
```js {title="app/api/my-cron-job/route.js"}
export async function GET(req, res) {
// Your job tasks here ...

// Ping URL
const URL = 'https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc';

// GET request to the Heartbeat
try {
const response = await fetch(URL);
console.log(`Checkly heartbeat ping status ${response.status}`);
} catch (error) {
console.log(`Checkly heartbeat ping failed: ${error}`)
}
}
```
{{< /tab >}}
{{< tab "Next.js (Pages Router)" >}}
```js {title="pages/api/my-cron-job.js"}
export default function handler(req, res) {
// Your job tasks here ...

// Ping URL
const URL = 'https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc';

// GET request to the Heartbeat
try {
const response = await fetch(URL);
console.log(`Checkly heartbeat ping status ${response.status}`);
} catch (error) {
console.log(`Checkly heartbeat ping failed: ${error}`)
}
}
```
{{< /tab >}}
{{< tab "Other frameworks" >}}
```js {title="api/my-cron-job.js"}
export function GET() {
// Your job tasks here ...

// Ping URL
const URL = 'https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc';

// GET request to the Heartbeat
try {
const response = await fetch(URL);
console.log(`Checkly heartbeat ping status ${response.status}`);
} catch (error) {
console.log(`Checkly heartbeat ping failed: ${error}`)
}
}
```
{{< /tab >}}
{{< /tabs >}}

## Python
This is an example using the Python [requests](https://requests.readthedocs.io/en/latest/) library with a timeout of 5 seconds:

```PYTHON {title="my_scheduled_job.py"}
import requests

# Heartbeat URL
url = "https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc"

# A GET request to the Heartbeat
response = requests.get(url, timeout=5)
```

## PowerShell
Use PowerShell and Windows Task Scheduler to automate tasks on Windows systems. Adding a ping to a PowerShell script only requires a single line.

We recommend using the `timeout` and `retry` options to reduce the risk of false alerts or blocking the script. See the [Invoke-RestMethod](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.3) documentation for more information.

```BASH
Invoke-RestMethod -Uri https://ping.checklyhq.com/c3f5f5bb-6e46-431a-b7b1-35105450cddc -TimeoutSec 5 -MaximumRetryCount 3 -RetryIntervalSec 5
```
20 changes: 19 additions & 1 deletion site/content/docs/monitoring/check-results.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ menu:
parent: "Monitoring"
---

You can select any check on the main Checkly dashboard to get an overview of the results they have produced so far. To learn about heartbeat check results, visit the [Heartbeat checks](/docs/heartbeat-checks/) section
You can select any check on the main Checkly dashboard to get an overview of the results they have produced so far.

## Check results overview

Expand Down Expand Up @@ -132,6 +132,24 @@ These include:

e. Download

## Heartbeat check results

Heartbeat check results show information about the ping request, like when it was recieved and its source.

![Using the Heartbeat check results view](/docs/images/monitoring/check-results-heartbeat.png)

The state indicates when your scheduled job pinged the Heartbeat check, relative to the expected time:

| State | Description |
| -------- | ------- |
| `EARLY` | Ping recieved before the expected time. |
| `RECEIVED` | Ping recieved right at the expected time. |
| `GRACE` | Ping recieved after the expected time, during the grace period. |
| `LATE` | Ping recieved during the few seconds between the end of the grace period and before the check is marked as failing. This is very rare. |
| `FAILING` | No ping recieved by the end of the grace period. Indicates a failing Heartbeat check. |

The source shows where your ping originated, determined by the `origin` and `referer` request headers. [Learn more about configuring the ping source](/docs/heartbeat-checks/#pinging-your-heartbeat-check).

## Multistep check results

Multistep check results are navigated using the tree on the left side of the screen. If you are running checks in parallel, first select the location you are interested in.
Expand Down
Loading