Salesforce alerting
The Salesforce data source supports Grafana Alerting, allowing you to create alert rules based on Salesforce data. You can monitor your Salesforce environment and receive notifications when specific conditions are met, such as when opportunity values drop, case counts spike, or tasks become overdue.
Before you begin
- Ensure you have the appropriate permissions to create alert rules in Grafana.
- Verify your Salesforce data source is configured and working correctly.
- Familiarize yourself with Grafana Alerting concepts.
Query requirements for alerting
Alert queries must return numeric data that Grafana can evaluate against a threshold. Use aggregate SOQL functions to return numeric values:
Note
Queries that return only text or non-numeric data cannot be used directly for alerting. Use aggregate functions to return numeric values.
Create an alert rule
To create an alert rule using Salesforce data:
- Go to Alerting > Alert rules.
- Click New alert rule.
- Enter a name for your alert rule.
- In the Define query and alert condition section:
- Select your Salesforce data source.
- Write a SOQL query that returns numeric data.
- Add a Reduce expression if your query returns multiple series.
- Add a Threshold expression to define the alert condition.
- Configure the Set evaluation behavior:
- Select or create a folder and evaluation group.
- Set the evaluation interval (how often the alert is checked).
- Set the pending period (how long the condition must be true before firing).
- Add labels and annotations to provide context for notifications.
- Click Save rule.
For detailed instructions, refer to Create a Grafana-managed alert rule.
Example: Open case count alert
This example creates an alert that fires when the number of open high-priority cases exceeds a threshold:
Create a new alert rule.
Configure the query:
SELECT COUNT() FROM Case WHERE IsClosed = false AND Priority = 'High'Add expressions:
- Reduce: Last value
- Threshold: Is above 50
Set evaluation to run every 5 minutes with a 10-minute pending period.
Save the rule.
Example: Opportunity pipeline alert
This example alerts when the total value of opportunities closing this month drops below a target:
Create a new alert rule.
Configure the query:
SELECT SUM(Amount) FROM Opportunity WHERE IsClosed = false AND CloseDate = THIS_MONTHAdd expressions:
- Reduce: Last value
- Threshold: Is below 1000000
Set evaluation to run every hour.
Save the rule.
Example: Overdue task alert
This example alerts when there are overdue tasks:
Create a new alert rule.
Configure the query:
SELECT COUNT() FROM Task WHERE IsClosed = false AND ActivityDate < TODAYAdd expressions:
- Reduce: Last value
- Threshold: Is above 0
Set evaluation to run every 15 minutes.
Save the rule.
Example: Lead conversion rate alert
This example alerts when lead conversion falls below an acceptable rate. First, create a query that returns the count of converted leads:
Create a new alert rule.
Configure the query:
SELECT COUNT() FROM Lead WHERE IsConverted = true AND ConvertedDate = THIS_WEEKAdd expressions:
- Reduce: Last value
- Threshold: Is below 10
Set evaluation to run daily.
Save the rule.
Best practices
Follow these recommendations to create reliable and efficient alerts with Salesforce data.
Use aggregate functions
Always use SOQL aggregate functions (COUNT, SUM, AVG, MIN, MAX) for alert queries. These return numeric values that Grafana can evaluate against thresholds.
Consider API limits
Salesforce has API request limits. Set alert evaluation intervals appropriately to avoid excessive API usage:
- Use longer intervals (5+ minutes) when possible.
- Avoid very short intervals (less than 1 minute) for non-critical alerts.
- Monitor your Salesforce API usage in Setup under System Overview.
Use date literals
SOQL provides date literals that simplify time-based filtering:
TODAY,YESTERDAY,TOMORROWTHIS_WEEK,LAST_WEEK,NEXT_WEEKTHIS_MONTH,LAST_MONTH,NEXT_MONTHTHIS_QUARTER,LAST_QUARTER,NEXT_QUARTERTHIS_YEAR,LAST_YEAR,NEXT_YEAR
Handle no data conditions
Configure what happens when no data is returned:
- In the alert rule, find Configure no data and error handling.
- Choose an appropriate action:
- No Data: Keep the alert in its current state
- Alerting: Treat no data as an alert condition
- OK: Treat no data as a healthy state
Test queries before alerting
Always verify your query returns expected data before creating an alert:
- Go to Explore.
- Select your Salesforce data source.
- Run the query you plan to use for alerting.
- Confirm the data format and values are correct.
Troubleshoot alerting issues
For common alerting issues with the Salesforce data source, refer to the Troubleshooting guide.
Common issues include:
- Alert not firing: Ensure your query returns numeric data using aggregate functions.
- Evaluation errors: Check that your SOQL syntax is valid and the query executes successfully in Explore.
- Timeouts: Simplify complex queries or increase the timeout setting in the data source configuration.



