Set Up

Step 1: Create a Cron Monitor

Sentry Cron Monitoring allows you to monitor any job running on a scheduled interval. To get started, create a new cron monitoring service for one of your projects:

  1. Select “Crons” from the sidebar.

  2. Click the "Set Up Cron Monitor" button. Set Up Cron Monitor

  3. In the details section, select the project to which you'd like your Cron Monitor to be attached. That's where you'll see any job execution issues.

  4. Name your job. For example, "Generate Daily Invoices".

  5. In the configuration section, enter the maximum number of minutes allowed for a job to run before it's considered failed. For example, if you enter 30, any job running for more than 30 minutes will be considered failed and a new issue will be generated.

  6. Select whether you'd like to schedule job monitors using Crontab syntax or time intervals:

    • Crontab: A Crontab schedule uses Crontab syntax. This works well if your job runs on a very rigorous schedule. Crontab syntax lets you verify if your job has run every day, every hour, or even in smaller increments. Learn more about the Crontab syntax. Crontab examples: Example of an every hour Crontab Example of a Crontab for every hour. Example of an every hour Crontab Example of a Crontab for every month on the 1st and 15th day.
    • Interval: If getting granular with scheduling is less important, the Interval schedule type may be better suited for your needs. It allows you to schedule your job to run every X years, hours, minutes, or anything in-between.
  7. Enter the acceptable number of minutes an expected check-in can be late by before it's considered failed, based on the schedule above. For example, if your monitor is configured as a Crontab of 0 * * * * (every hour at minute 0) and the check-in margin is defined as 10 minutes, your job won't be considered failed as long as it checks in by hour X, minute 10.

  8. Click on "Next Steps" at the bottom of the page to configure your health checks.

Step 2: Set Up Health Checks

Sentry monitors your job status via regular health checks emitted by your application. A health check consists of two (2) HTTP "check-in" requests: an initial request emitted before the start of your job execution to create a check-in, and a final update request emitted after your job completes, to update the status of your check-in.

Creating these health checks can be done automatically, using Sentry's CLI, or manually via HTTP. To get started, install and configure your CLI, or simply use the example below to construct an HTTP request in your favorite language:

# sentry-cli monitors run <monitor_id> -- <command> <args>

# Example for a Python job:
sentry-cli monitors run 63261d96-2027-472a-a8bb-9895dbebd793 -- python path/to/

Request Parameters

Required. Your monitor ID can be found on the monitor details page. Monitor Id

Required. The status of your job execution and whether it was completed successfully or unsuccessfully. The values accepted are in_progress, ok or error.

Required. The check-in id to use when updating a check-in to mark the completion or failure of a scheduled job. You can also supply "latest" for this parameter in order to retrieve the most recent check-in, more info in the API documentation

Optional. The runtime of the job in milliseconds. If this value is not provided, a duration will be automatically calculated based on the amount of time elapsed from check-in creation to updating a check-in as successful or failed.

More API docs can be found in the API documentation.

Once these health checks are set up, your Cron Monitor is ready to observe and report on future scheduled job executions.

To verify that everything is set up correctly make sure that you are receiving recent check-ins with an "ok" status.

Example Recent Monitor Check-In

If your own cron monitor isn't producing "ok" check-ins even when running as expected, consult the troubleshooting section.

Next Steps

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").