Setting Up Database Monitoring for self-hosted SQL Server

Database Monitoring is not supported for this site.

Database Monitoring for SQL Server is in private beta. Contact your Customer Success Manager to request access to the beta.

Database Monitoring provides deep visibility into your Microsoft SQL Server databases by exposing query metrics, query samples, explain plans, database states, failovers, and events.

Do the following steps to enable Database Monitoring with your database:

  1. Grant the Agent access to the database
  2. Install the Agent

Before you begin

Supported SQL Server versions
2012, 2014, 2016, 2017, 2019
Supported Agent versions
7.35.0+
Performance impact
The default Agent configuration for Database Monitoring is conservative, but you can adjust settings such as the collection interval and query sampling rate to better suit your needs. For most workloads, the Agent represents less than one percent of query execution time on the database and less than one percent of CPU.

Database Monitoring runs as an integration on top of the base Agent (see benchmarks).
Proxies, load balancers, and connection poolers
The Agent must connect directly to the host being monitored. The Agent should not connect to the database through a proxy, load balancer, or connection pooler. While this can be an anti-pattern for client applications, for Database Monitoring each Agent must have knowledge of the underlying host and should stick to a single host for its lifetime, even in cases of failover. If the Datadog Agent connects to different hosts while it is running, then the metrics will be incorrect.
Data security considerations
Read about how Database Management handles sensitive information for information about what data the Agent collects from your databases and how to ensure it is secure.

Grant the Agent access

The Datadog Agent requires read-only access to the database server in order to collect statistics and queries.

Create a read-only login to connect to your server and grant the required permissions:

CREATE LOGIN datadog WITH PASSWORD = '<PASSWORD>';
CREATE USER datadog FOR LOGIN datadog;
GRANT CONNECT ANY DATABASE to datadog;
GRANT VIEW SERVER STATE to datadog;
GRANT VIEW ANY DEFINITION to datadog;

Install the Agent

It’s recommended to install the agent directly on the SQL Server host as that enables the agent to collect a variety of system telemetry (CPU, memory, disk, network) in addition to SQL Server specific telemetry.

To start collecting SQL Server telemetry, first install the Datadog Agent.

Create the SQL Server Agent conf file C:\ProgramData\Datadog\conf.d\sqlserver.d\conf.yaml. See the sample conf file for all available configuration options.

init_config:
instances:
  - dbm: true
    host: '<HOSTNAME>,<SQL_PORT>'
    username: datadog
    password: '<PASSWORD>'
    connector: adodbapi
    provider: MSOLEDBSQL
    tags:  # optional
      - 'service:<CUSTOM_SERVICE>'
      - 'env:<CUSTOM_ENV>'

To use Windows Authentication set connection_string: "Trusted_Connection=yes" and omit the username and password fields.

The service and env tags allow you to link your database telemetry to other telemetry through a common tagging scheme. To learn how these tags are used throughout Datadog, read the documentation on unified service tagging.

Supported Drivers

Microsoft ADO

The recommended ADO provider is Microsoft OLE DB Driver. Ensure the driver is installed on the host where the agent is running.

connector: adodbapi
provider: MSOLEDBSQL

The other two providers, SQLOLEDB and SQLNCLI, are considered deprecated by Microsoft and should no longer be used.

ODBC

The recommended ODBC driver is Microsoft ODBC Driver. Ensure the driver is installed on the host where the Agent is running.

connector: odbc
driver: '{ODBC Driver 17 for SQL Server}'

Once all Agent configuration is complete, Restart the Datadog Agent.

Validate

Run the Agent’s status subcommand and look for sqlserver under the Checks section. Navigate to the Databases page in Datadog to get started.

To start collecting SQL Server telemetry, first install the Datadog Agent.

On Linux, the Datadog Agent additionally requires an ODBC SQL Server driver to be installed—for example, the Microsoft ODBC driver. Once an ODBC SQL Server is installed, copy the odbc.ini and odbcinst.ini files into the /opt/datadog-agent/embedded/etc folder.

Use the odbc connector and specify the proper driver as indicated in the odbcinst.ini file.

Create the SQL Server Agent conf file /etc/datadog-agent/conf.d/sqlserver.d/conf.yaml. See the sample conf file for all available configuration options.

init_config:
instances:
  - dbm: true
    host: '<HOSTNAME>,<SQL_PORT>'
    username: datadog
    password: '<PASSWORD>'
    connector: odbc
    driver: '<Driver from the `odbcinst.ini` file>'
    tags:  # optional
      - 'service:<CUSTOM_SERVICE>'
      - 'env:<CUSTOM_ENV>'

The service and env tags allow you to link your database telemetry to other telemetry through a common tagging scheme. To learn how these tags are used throughout Datadog, read the documentation on unified service tagging.

Once all Agent configuration is complete, Restart the Datadog Agent.

Validate

Run the Agent’s status subcommand and look for sqlserver under the Checks section. Navigate to the Databases page in Datadog to get started.

Further reading