This framework allows users to schedule snapshots of org limits and configure alerts on it.
Important
Org Limit Tracking Framework is not an official Salesforce product, it has not been officially tested or documented by Salesforce.
The configuration is based on two objects:
- OrgSnapshot__c: Stores the org limit snapshot defined by the frequency of the scheduled job.
- OrgSnapshotAlert__c: Configures alerts for users when a particular threshold is reached.
You can customize if the alert must be sent to a user or public group by email and/or by custom notification.
Important
Prerequisite: At least one OrgSnapshotAlert__c record must be configured for the batch job to create any snapshots. If no alert records exist, no snapshots will be saved to the database.
Two Permission Sets are defined for this framework:
- OrgSnapshotUser: Gives read access to
OrgSnapshot__c - OrgSnapshotAdmin: Gives read and write access to
OrgSnapshot__c,OrgSnapshotAlert__c, and related batch classes.
The batch class OrgSnapshotBatch can be executed in two modes:
- Full Mode (
isPartial = false) → Saves all org limits toOrgSnapshot__c. - Partial Mode (
isPartial = true) → Saves only limits that have a matchingOrgSnapshotAlert__c.
// Full Mode: Save all org limits
Database.executeBatch(new OrgSnapshotBatch(false));
// Partial Mode: Save only limits with alerts configured
Database.executeBatch(new OrgSnapshotBatch(true));// Run the batch every day at midnight
String cronExp = '0 0 0 * * ?';
System.schedule('Daily OrgSnapshotBatch', cronExp, new OrgSnapshotBatch(false));👉 For scheduling every 15 minutes, create multiple cron jobs.
Before running the batch, you need to create at least one OrgSnapshotAlert__c record. Here's an example for monitoring DailyDeliveredPlatformEvents with a 90% threshold:
// Create an alert for DailyDeliveredPlatformEvents at 90% threshold
OrgSnapshotAlert__c alert = new OrgSnapshotAlert__c(
Name = 'Daily Platform Events Alert',
Limit__c = 'DailyDeliveredPlatformEvents',
Threshold__c = 90.0,
User__c = UserInfo.getUserId(), // Alert current user
Email__c = 'admin@company.com', // Optional: CC email address
SendCustomNotification__c = true, // Send custom notifications
NotificationInterval__c = 60 // Wait 60 minutes between alerts
);
insert alert;You can also create alerts for other org limits such as:
DataStorageMBFileStorageMBDailyApiRequestsHourlyTimeBasedWorkflow- And many others...
You can schedule the OrgSnapshotBatchSchedulable class to execute periodically.
Warning
For schedules that are less than a 1-hour period, you will have to create different cron jobs, ie for 15 minutes jobs:
System.schedule('Daily OrgSnapshotBatch 0', '0 0 * * * ?', new OrgSnapshotBatch(false));
System.schedule('Daily OrgSnapshotBatch 15', '0 15 * * * ?', new OrgSnapshotBatch(false));
System.schedule('Daily OrgSnapshotBatch 30', '0 30 * * * ?', new OrgSnapshotBatch(false));
System.schedule('Daily OrgSnapshotBatch 45', '0 45 * * * ?', new OrgSnapshotBatch(false));These schedules will count against the 100 scheduled Apex jobs limit. More details in the Salesforce documentation.
A comprehensive dashboard is included to monitor the evolution of your DailyDeliveredPlatformEvents org limit usage over time. The dashboard provides:
- Line charts showing usage trends and limit utilization percentage
- Bar charts for recent daily usage patterns
- Key metrics including average usage, peak usage, and current limits
- Detailed data table for precise inspection
Access the dashboard: Navigate to the "Org Snapshot" app → Dashboards tab → "Daily Delivered Platform Events - Monitoring Dashboard"
For detailed documentation, see DASHBOARD_README.md.
To prevent alert spam, you can configure a notification interval for each alert. This setting determines the minimum time that must pass between consecutive alerts for the same limit.
- NotificationInterval__c: Time in minutes between two notifications for the same limit
- If not set (null), alerts will be sent every time the threshold is reached
- If set, alerts will only be sent if enough time has passed since the last alert
- The interval is checked for both email notifications and custom notifications
Based on the frequency of the schedule you define, the framework can create lots of records. You can manage OrgSnapshot__c purge with the framework SObject Purge Framework.
Checkout the repo and deploy it with sfdx:
sf project deploy start -p force-appUse GitHub Salesforce Deploy Tool:
