This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.
Microsoft SQL Server data source
Microsoft SQL Server (MSSQL) is one of the most widely used relational databases for business applications, analytics, and operational workloads. The MSSQL data source lets you query your existing SQL Server instance directly from Grafana, with no data migration required.
The data source ships with Grafana out of the box. It’s preinstalled in both Grafana OSS and Grafana Enterprise, so there’s nothing for you to install. Starting with Grafana 13.2, it’s packaged as a standalone plugin that updates independently of Grafana releases. Refer to Plugin updates for details.
You can connect to Microsoft SQL Server 2012 or newer, Azure SQL Database, and Azure SQL Managed Instance.
Supported features
Supported versions
Grafana recommends using the latest available service pack for optimal compatibility.
Authentication methods
The Microsoft SQL Server data source supports the following authentication methods:
Note
Azure Entra ID (Current User) authentication doesn’t support alerting, reporting, or recorded queries because these features run on the backend without a user session.
For configuration details, refer to Configure the Microsoft SQL Server data source.
Get started
The following documentation helps you set up and use the Microsoft SQL Server data source:
Plugin updates
Starting with Grafana 13.2, the Microsoft SQL Server data source is a standalone plugin, preinstalled in both Grafana OSS and Grafana Enterprise. This enables more frequent updates independent of Grafana releases. Grafana automatically checks the plugin catalog and installs the latest version on each server restart.
To adjust this behavior:
- Opt out of auto-updates: Set
preinstall_auto_updatetofalsein your configuration file. - Update manually: Update at any time from the Administration > Plugins page without restarting Grafana.
The standalone plugin requires Grafana 12.3.0 or later. The Microsoft SQL Server data source bundled with Grafana 13.1 and earlier continues to work as before. These versions are unaffected by the change.
Users running Grafana 12.3.x through 13.1.x can install the standalone plugin from the plugin catalog if they want the latest features before upgrading to Grafana 13.2. To use the standalone plugin with Grafana 12.3.x through 13.1.x, add the following to your configuration file:
[plugin.mssql]
as_external = true
[plugins]
; Install the latest version on startup:
preinstall_sync = mssql
; Or install a specific version:
; preinstall_sync = mssql@<version>Additional features
After you configure the data source, you can:
- Use Explore to query data without building a dashboard
- Create visualizations including time series, tables, and gauges
- Add transformations to manipulate query results
- Optimize performance with query caching (Grafana Enterprise and Cloud)
Query with the Grafana CLI
You can query this data source from the command line and from AI coding agents using the Grafana CLI, gcx. gcx gives you and your agent structured, terminal-based access to your Grafana data sources, which is useful for automation and agent-driven investigations.
gcx supports Grafana Cloud and Grafana OSS or Enterprise v12 and later. Before you query, install and authenticate gcx. Refer to the
gcx CLI documentation for installation, configuration, and the full command reference.
For example, to explore and query your Microsoft SQL Server data source, use the gcx datasources mssql commands:
# List tables and views, or filter to a single schema
gcx datasources mssql list-tables -d <DATASOURCE_UID>
gcx datasources mssql list-tables -d <DATASOURCE_UID> --schema dbo
# Show the columns of a table
gcx datasources mssql describe-table dbo.WORLD_DATA -d <DATASOURCE_UID>
# Run a SQL query (server-side macros like $__timeFilter are supported)
gcx datasources mssql query -d <DATASOURCE_UID> 'SELECT * FROM events WHERE $__timeFilter(created_at)' --since 1hReplace <DATASOURCE_UID> with the UID of your Microsoft SQL Server data source. You can omit the -d flag when datasources.mssql is configured in your gcx context. The query command supports Grafana server-side macros such as $__timeFilter and $__timeGroup, and because T-SQL has no LIMIT, results are capped with an injected TOP (n) clause, which you can disable with --limit 0. The list-tables and describe-table commands read INFORMATION_SCHEMA for the data source’s configured database.


