Skip to main content

Cron Monitors

Cron monitors track scheduled jobs by expecting regular check-ins. If a check-in is missed, an alert is triggered.

Endpoints

MethodPathDescription
GET/cron_monitorsList all cron monitors
GET/cron_monitors/:idGet a specific monitor
POST/cron_monitorsCreate a monitor
PUT/cron_monitors/:idUpdate a monitor
DELETE/cron_monitors/:idDelete a monitor

Cron Monitor Object

{
"id": "xyz789",
"title": "Daily Backup",
"cron_id": "550e8400-e29b-41d4-a716-446655440000",
"cron_url": "https://beepr.io/api/cron/550e8400-e29b-41d4-a716-446655440000",
"interval": 1440,
"alert_group_id": "abc123",
"status": "up",
"check_deadline": "2024-01-16T02:00:00Z",
"configured_at": "2024-01-15T02:00:00Z",
"external_id": "daily-backup",
"inserted_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}

Fields

FieldTypeDescription
titlestringName of the monitor (required)
intervalintegerExpected interval in minutes (required)
alert_group_idstringAlert group to notify (required)
cron_idstringUUID for the check-in URL (generated)
cron_urlstringFull URL for check-ins (generated)
statusstringCurrent status: up, down, or pending
check_deadlinestringWhen next check-in is expected
external_idstringYour identifier for idempotent operations

Create a Cron Monitor

curl -X POST https://beepr.io/api/v1/cron_monitors \
-H "Authorization: Bearer bpr_your_key" \
-H "Content-Type: application/json" \
-d '{
"alert_group_id": "abc123",
"title": "Daily Backup",
"interval": 1440,
"external_id": "daily-backup"
}'

The response includes cron_url which your job should ping when it completes.

Sending Check-ins

Once created, have your cron job make a GET or POST request to the cron_url:

# In your crontab
0 2 * * * /path/to/backup.sh && curl -s https://beepr.io/api/cron/550e8400...

Example: Ansible Playbook

The API returns 201 Created for new monitors and 200 OK when updating an existing one (via external_id). You can use this to make your playbook report accurate change status:

- name: Ensure backup monitor exists
uri:
url: "https://beepr.io/api/v1/cron_monitors"
method: POST
headers:
Authorization: "Bearer {{ beepr_api_key }}"
Content-Type: "application/json"
body_format: json
body:
alert_group_id: "{{ alert_group_id }}"
title: "{{ inventory_hostname }} - Daily Backup"
interval: 1440
external_id: "{{ inventory_hostname }}-backup"
status_code: [200, 201]
register: monitor
changed_when: monitor.status == 201

- name: Add check-in to crontab
cron:
name: "Daily backup with Beepr check-in"
hour: "2"
minute: "0"
job: "/opt/backup.sh && curl -s {{ monitor.json.data.cron_url }}"

The changed_when: monitor.status == 201 line ensures Ansible shows:

  • changed when a new monitor was created (201)
  • ok when the monitor already existed (200)

For the complete schema, see the OpenAPI specification.