Lean20 Support Center

Contact Us

What Is A Heartbeat

Overview

Heartbeats are similar to Monitors, but instead of Lean20 reaching out, your process does a "check-in" to report that it is online. When a scheduled check-in is missed your team will be alerted. These are useful for services that are not exposed to the public internet, cron jobs, lambda functions, or anything similar.

The schedule of the expected check-in is defined by the interval of the heartbeat. For example, you create a Heartbeat with an interval of 1 hour. At 12:32pm your service reports in and we record it. If we don't see another check-in by 1:32pm then we consider the Heartbeat missed and will alert you. You will be alerted for every check-in that is missed.

Note: We do not start monitoring a Heartbeat's schedule until we see the first check-in.


When creating a new Heartbeat you need to provide a name and an interval. The interval is a time period in minutes that you would like the Heartbeat analyzed. A check-in is a simple GET request to the URL given to your monitor. We will respond with a JSON payload indicating success and a timestamp of the next expected check-in. An alert will go out if we do not see another check-in by that expected time.


Record a check-in

Reporting a check-in is just a simple GET request to the Url we assigned your monitor. No authentication, special headers, payload, or parameters are required.

Let's say you have a shell script that generates an internal report on a nightly basis. You want to be alerted if the job doesn't run completely; so you create a Heartbeat with an interval of 1440 minutes.


Your shell script may look something like this:

#!/bin/sh
# Build nightly report for finance
echo Generating report
#...

# record a check-in to Lean20
curl https://heartbeats.lean20.com/v1/record/jOE2qUH_


The last line in the script is simply requesting the URL we gave you. We will record the Heartbeat and wait for the next one tomorrow. Of course, you aren't limited to shell scripting. You could do it in Node, Python, C#, etc... As part of a lambda function, a Windows Batch file as part of a scheduled task, or any other way you see fit.


Example Heartbeats and Alerts

If you have a Heartbeat created that expects a check-in every 5 minutes, we will alert you for everyone missed. It may look something like this.

1:01pm - You create the Heartbeat with an interval of 5 minutes. We put it in a "hold" state waiting for the first check-in
2:05pm - The first check-in is recorded and we now expect subsequent check-ins starting now
2:10pm - A second check-in is recorded
2:15pm - No check-in was recorded; an alert is sent out
2:20pm - Check-in recorded
2:25pm - No check-in was recorded; an alert is sent out
2:30pm - No check-in was recorded; an alert is sent out
2:35pm - Check-in recorded