Overview
The most common way to use CronJob Guardian is to create aCronJobMonitor that watches specific CronJobs based on labels or names. This page shows simple, practical examples to get you started.
Monitor CronJobs by Label
The most flexible approach is to use label selectors. This allows you to add monitoring to any CronJob by simply adding a label.monitors/basic.yaml
What This Does
- Monitors all CronJobs in the
productionnamespace with labeltier: critical - Triggers an alert if no successful run in 25 hours (dead-man’s switch)
- Tracks success rate and alerts if it drops below 99% over 7 days
- Sends alerts to the
slack-opsAlertChannel
Setup Instructions
Label your CronJobs
Add the Or add it directly in your CronJob YAML:
tier: critical label to CronJobs you want to monitor:Create an AlertChannel
Before creating the monitor, you need at least one AlertChannel. See the Slack Alerts guide.
Monitor All CronJobs in a Namespace
If you want to monitor every CronJob in a namespace without adding labels, use an empty selector.monitors/all-in-namespace.yaml
What This Does
- Monitors every CronJob in the
productionnamespace - No labels required on your CronJobs
- Simpler configuration for smaller teams or less critical environments
When to Use This
- Small namespaces with only critical jobs
- Dev/staging environments where you want blanket monitoring
- When you trust all jobs in the namespace to be monitored the same way
Monitor Specific CronJobs by Name
For precise control, specify exact CronJob names.What This Does
- Monitors only the two named CronJobs:
daily-revenue-reportandweekly-summary - Other CronJobs in the namespace are ignored
- Useful when you have a small set of critical jobs
matchNames only works when monitoring a single namespace. For multi-namespace monitoring, use label selectors instead.Advanced Label Selectors
For more complex filtering, usematchExpressions with operators like In, NotIn, Exists, and DoesNotExist.
What This Does
- Monitors CronJobs with
tier: criticalORtier: high - Excludes CronJobs with
monitoring: disabledlabel - Gives you fine-grained control over what gets monitored
Adjusting Dead-Man’s Switch Timing
ThemaxTimeSinceLastSuccess should be set based on your CronJob’s schedule:
Tuning SLA Thresholds
Adjust success rate requirements based on your job’s criticality:Next Steps
Namespace Monitoring
Monitor CronJobs across multiple namespaces
Advanced Features
SLA tracking, regression detection, and maintenance windows
Slack Alerts
Set up Slack notifications for your monitors
Alert Channels
Learn about all alert channel types