Salesforce Grafana data source [beta]
The Salesforce data source plugin allows you to visualize data from Salesforce in Grafana.
This is a beta version and subject to change. Unexpected issues might occur.
The Salesforce data source has the following requirements:
- Valid license for Grafana Enterprise; refer to Activate an Enterprise license.
- Grafana user with a server or organization administration role; refer to Permissions.
- A Salesforce account.
- A Salesforce Connected App.
- Ad-hoc filters are not supported yet.
- Only SOQL queries, and data that is accessible via SOQL are currently supported. SOSL and SAQL query formats are not yet supported.
Install the plugin
To install the data source, refer to Installation.
Prerequisite [Salesforce Connected App]
A Salesforce Connected App. ** Note:** The plugin currently uses the OAuth 2.0 Username-Password Flow. The required callback URL in the Connected App is not used. Thus, you can set it to any valid URL.
Required settings for the Grafana plugin
- Enable OAuth settings
- Check this to enable Oauth.
- Callback URL
- This is required in Salesforce but not used by the plugin. You can use any valid URL.
- Selected OAuth Scopes (minimum requirements)
- Access and Manage your data (api)
- Require Secret for Refresh Token Flow
- This can be enabled or disabled
Configure the data source in Grafana
Add a data source by filling in the following fields:
- User Name
- The user name for the Salesforce account you want to use to connect and query Salesforce.
- The password and Security Token, combined together, for the above user.
- Consumer Key
- A Consumer key to connect to Salesforce. You can obtain this from your Connected App
- Consumer Secret
- A Consumer secret to connect to Salesforce. You can obtain this from your Connected App
- Use Sandbox
- Select this if you want to use a Salesforce sandbox.
Configure the data source with provisioning
It is possible to configure data sources using configuration files with Grafana’s provisioning system. To learn more, read about how it works and about all the settings for data sources at Provisioning Grafana.
apiVersion: 1 datasources: - name: Salesforce type: grafana-salesforce-datasource editable: true enabled: true jsonData: user: user name secureJsonData: password: password clientID: consumer key clientSecret: consumer secret
Query the data source
The query editor supports SOQL (Salesforce Object Query Language).
Press Ctrl + Space to show code completion, which will show available contextual options.
Cmd + S runs the query.
Query as time series
Make a time series query by aliasing a date field to
time, and a metric field to
metric, then grouping by the metric and date.
The following is an example:
SELECT sum(Amount) amount, CloseDate time, Type metric from Opportunity group by Type, CloseDate
To filter by the dashboard time range, you can use Macros in your SOQL queries:
- Will be replaced by the start of the currently active time selection converted to
- Will be replaced by the end of the currently active time selection converted to
SELECT UserId, LoginTime from LoginHistory where LoginTime > $__timeFrom
Templates and variables
To add a new Salesforce query variable, refer to Add a query variable. Use your Salesforce data source as your data source. You can use any SOQL query here.
If you want to use name/value pairs, for example a user id and user name, return 2 fields from your SOQL query. The first field will be used as the ID. You may want to do this when you want to filter by key (ID, etc) in your query editor SOQL.
Use the variable in your SOQL queries by using Variable syntax.
For more information about variables, refer to Templates and variables.