How the scheduler works
At API startup, the scheduler registers each job with a cron expression read from environment variables. Each job fires at its scheduled time in a dedicated goroutine. When a job fires:- A
job_executionrecord is created withstatus=runningand a start timestamp. - The job function runs with a timeout.
- On completion, the record is updated with
status=succeededorstatus=failed, the end timestamp, duration, and a log snippet.
Job types
resource_sync — every 6 hours
resource_sync — every 6 hours
Pulls the latest resource inventory from all connected providers.What it does:
- Calls the cloud provider API for each connected account
- Creates records for newly discovered resources
- Updates configuration snapshots for existing resources
- Marks resources as
deletedwhen they no longer appear in API responses - Captures a new baseline for any resource whose configuration changed
0 */6 * * *drift_detection — every 4 hours
drift_detection — every 4 hours
Compares current resource state against baselines and creates drift findings.What it does:
- For each active resource with a baseline, runs the JSON diff algorithm
- Creates new
driftrecords for detected differences - Resolves existing drift records where the configuration has returned to the baseline state
- Triggers recommendation generation for new critical and high-severity drifts
0 */4 * * *vulnerability_scan — daily at 02:00 UTC
vulnerability_scan — daily at 02:00 UTC
Scans container images and resource artifacts for CVEs.What it does:
- Identifies scannable artifacts (container images from Kubernetes pods, EC2 AMIs)
- Runs Trivy against each artifact
- Enriches findings with NVD metadata (CVSS scores and descriptions)
- Creates or updates
vulnerabilityrecords - Closes findings for artifacts that no longer have the vulnerability
0 2 * * *cost_sync — daily at 03:00 UTC
cost_sync — daily at 03:00 UTC
Fetches and stores billing data from all connected cloud providers.What it does:
- Calls AWS Cost Explorer, GCP BigQuery, or Azure Cost Management for each connected provider
- Inserts daily cost records into the database
- Runs the anomaly detection check on the new data point
- Generates and caches updated cost forecasts
0 3 * * *compliance_check — daily at 04:00 UTC
compliance_check — daily at 04:00 UTC
Runs all enabled compliance frameworks against current resource snapshots.What it does:
- Evaluates all controls for each enabled framework against cached resource configuration
- Creates
assessmentandcontrol_resultrecords - Triggers alerts for controls that newly fail
- Triggers recommendation generation for failed controls
0 4 * * *Trigger a job manually
You don’t have to wait for the next scheduled run. Trigger any job on demand:View execution history
Each job execution record stores the job type, status, start and end times, duration, log output (last 1,000 lines), and any error message.Override the default schedule
Set any job’s schedule via environment variable before starting the API:Leader election for multi-instance deployments
When you run multiple API instances, only one should execute scheduled jobs to avoid duplicate scans and findings. InfraAudit implements leader election via a database lock in thejobs table. Each instance tries to acquire the lock at startup. Only the leader instance runs the scheduler. If the leader goes down, another instance acquires the lock within 60 seconds.
Leader election requires all API instances to share the same PostgreSQL database. If instances are using separate databases, each will run its own scheduler independently.