Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Configure the Microsoft SQL Server data source
This document provides instructions for configuring the Microsoft SQL Server data source and explains available configuration options. For general information on adding and managing data sources, refer to Grafana data sources and Data source management.
Before you begin
Grafana comes with a built-in MSSQL data source plugin, eliminating the need to install a plugin.
You must have the
Organization administratorrole to configure the MSSQL data source. Organization administrators can also configure the data source via YAML with the Grafana provisioning system.Familiarize yourself with your MSSQL security configuration and gather any necessary security certificates and client keys.
Verify that data from MSSQL is being written to your Grafana instance.
Add the MSSQL data source
To add the MSSQL data source, complete the following steps:
- Click Connections in the left-side menu.
- Click Add new connection
- Type
Microsoft SQL Serverin the search bar. - Select Microsoft SQL Server under data source.
- Click Add new data source in the upper right.
Grafana takes you to the Settings tab, where you will set up your Microsoft SQL Server configuration.
Configure the data source in the UI
Following are configuration options for the Microsoft SQL Server data source.
Warning
Kerberos is not supported in Grafana Cloud.
Connection:
TLS/SSL Auth:
Encrypt - Determines whether or to which extent a secure SSL TCP/IP connection will be negotiated with the server.
Note
If you’re using an older version of Microsoft SQL Server like 2008 and 2008R2, you may need to disable encryption to be able to connect.
Authentication:
Additional settings:
Additional settings are optional settings you configure for more control over your data source. This includes connection limits, connection timeout, group-by time interval, and Secure Socks Proxy.
Connection limits:
Connection details:
Windows ADS Advanced Settings
Private data source connect - Only for Grafana Cloud users.
Private data source connect, or PDC, allows you to establish a private, secured connection between a Grafana Cloud instance, or stack, and data sources secured within a private network. Click the drop-down to locate the URL for PDC. For more information regarding Grafana PDC refer to Private data source connect (PDC) and Configure Grafana private data source connect (PDC) for instructions on setting up a PDC connection.
Click Manage private data source connect to open your PDC connection page and view your configuration details.
After configuring your MSSQL data source options, click Save & test at the bottom to test the connection. You should see a confirmation dialog box that says:
Database Connection OK
Min time interval
The Min time interval setting defines a lower limit for the
$__interval and [$__interval_ms][add-template-variables-interval_ms] variables.
This value must be formatted as a number followed by a valid time identifier:
Grafana recommends setting this value to match your Microsoft SQL Server write frequency.
For example, use 1m if Microsoft SQL Server writes data every minute.
You can also override this setting in a dashboard panel under its data source options.
Database user permissions
When adding a data source, ensure the database user you specify has only SELECT permissions on the relevant database and tables. Grafana does not validate the safety of queries, which means they can include potentially harmful SQL statements, such as USE otherdb; or DROP TABLE user;, which could get executed. To minimize this risk, Grafana strongly recommends creating a dedicated MySQL user with restricted permissions.
CREATE USER grafanareader WITH PASSWORD 'password'
GRANT SELECT ON dbo.YourTable3 TO grafanareaderAlso, ensure that the user doesn’t have any unwanted privileges from the public role.
Diagnose connection issues
If you use older versions of Microsoft SQL Server, such as 2008 and 2008R2, you might need to disable encryption before you can connect the data source.
Grafana recommends that you use the latest available service pack for optimal compatibility.
Provision the data source
You can define and configure the data source in YAML files as part of the Grafana provisioning system. For more information about provisioning, and for available configuration options, refer to Provision Grafana.
Provisioning example
apiVersion: 1
datasources:
- name: MSSQL
type: mssql
url: localhost:1433
user: grafana
jsonData:
database: grafana
maxOpenConns: 100
maxIdleConns: 100
maxIdleConnsAuto: true
connMaxLifetime: 14400
connectionTimeout: 0
encrypt: 'false'
secureJsonData:
password: 'Password!'


