Heartbeat monitoring is a time-tested method of tracking the health of a device or software system by sending regular heartbeat events to a remote monitoring service. Alerts are triggered when:
In this guide:
Heartbeat monitors can be configured in a variety of ways. A complete list of monitor attributes can be found in the Monitor API documentation.
# the unique identifier (key)
airflow-heartbeat:
# configure monitor as a heartbeat
type: 'heartbeat'
# When events will be sent to Cronitor (also supports cron and HH:MM 24hr time expressions)
schedule: 'every 60 seconds'
# assertions based on data along with the heartbeat event
assertions:
- 'metric.error_count < 3'
# who to notify when Cronitor detects a problem
notify:
- 'slack:#devops-alerts'
Cronitor's open-source SDKs support managing the configuration of all your monitors from a single YAML configuration file, which be synced with Cronitor as part of your build or deploy process.
The following Python example is representative of how this works across our SDKs.
import cronitor
cronitor.api_key = '<API-KEY>'
cronitor.config = '/path/to/cronitor.yaml'
cronitor.apply_config() # send monitor configuration to Cronitor
Once a monitor has been created, it will remain in an inactive state until it receives its first heartbeat event. Events are sent using Cronitor's Telemetry API.
A basic heartbeat is any GET, POST or HEAD request to the URL
curl https://cronitor.link/p/<API-KEY>/airflow-heartbeat
Cronitor can send alerts via many different channels, including: Email, Slack, PagerDuty, Microsoft Teams, SMS, webhooks and more.
Notification lists are configurable sets of channels that are attached to your monitors. When a monitor fails or recovers, an alert will be sent to every channel/recipient on the attached list. You can create or modify a list from the Notification Lists section of your settings page.
In the monitor's edit form locate the Alert Receipients panel. You may choose to add a notification list or add channels/recipients directly (or both).
Specify alert recipients adding a notify
array to your monitor JSON as shown below. Notification lists are attached using their unique key.
curl -X POST https://cronitor.io/api/monitors \ -u <API-KEY>: \ -H "Content-Type: application/json" -d '{ "key": "Database Backup", "type": "job", "schedule": "0 */3 * * 1-5", "notify": ['devops-emergency'] }'
Tip: When your Cronitor account is created a list named "Default" will automatically be created, and your email address will be added to it. When no list is specified the default list will be used.
cronitor configure --ping-api-key <KEY>
or set the CRONITOR_PING_API_KEY
environment variable.
If you're sending pings using Curl or a native HTTP client, provide the key via an &auth_key
parameter.
/r
, /c
and /f