MSSQL monitoring integration

New Relic Infrastructure's MSSQL integration reports data from your Microsoft (MS) SQL Server environment to New Relic Infrastructure. This document explains how to install and configure the MSSQL integration and describes the data collected.

This integration is released as open source under the MIT license on Github. A change log is also available there for the latest updates.


Access to this feature depends on your subscription level. Requires Infrastructure Pro.

The New Relic MSSQL on-host integration collects and sends inventory and metrics from your MS SQL Server environment to New Relic Infrastructure, where you can see at-a-glance the health of your MS SQL Server environment. Database- and instance-level metrics are collected so that you can more easily find the source of any problems that arise.

Compatibility and requirements

To use the MSSQL integration, ensure your system meets these requirements:

MS SQL users and privileges

In the MS SQL Server that is to be monitored, execute the following script to create a new user and grant CONNECT, VIEW SERVER STATE, and read access permissions to that user. Note: login_name, user_name, tmp_password and similar user-specific values must be replaced. To help prevent login issues, it is recommended that login_name and user_name be the same value.

See the Microsoft documentation for details on creating logins and users in MS SQL Server.

The MSSQL Integration currently only supports SQL Authentication.

  1. Use the following statements to create a new login and new user, and to grant CONNECT and VIEW SERVER STATE permissions to the user.
    USE master;
    CREATE LOGIN login_name WITH PASSWORD = 'tmp_password';
    CREATE USER user_name FOR LOGIN login_name;
    GRANT CONNECT SQL TO login_name;
  2. Use the following statements to grant read access privileges to the user.
    DECLARE @name NVARCHAR(max)
    DECLARE db_cursor CURSOR FOR
    FROM master.dbo.sysdatabases
    WHERE NAME NOT IN ('master','msdb','tempdb','model')
    OPEN db_cursor
        EXECUTE('USE "' + @name + '"; CREATE USER user_name FOR LOGIN login_name;' );
        FETCH next FROM db_cursor INTO @name
    CLOSE db_cursor
    DEALLOCATE db_cursor
  3. Run the following command to verify that the user was successfully created.
    sqlcmd -U user_name -S host_name


On-host integrations do not automatically update. For best results, you should occasionally update the integration and update the Infrastructure agent.

To install the MSSQL integration:

  1. Download the latest .MSI installer image from:

    32-bit Windows
    64-bit Windows
  2. In an admin account, run the install script using an absolute path. To install from the Windows command prompt, run:

    32-bit Windows
    msiexec.exe /qn /i PATH\TO\nri-mssql-amd386.msi
    64-bit Windows
    msiexec.exe /qn /i PATH\TO\nri-mssql-amd64.msi
  3. Change C:\Program Files\New Relic\newrelic-infra\integrations.d\mssql-config.yml.sample to mssql-config.yml, and edit according to your instance.
  4. Restart the infrastructure agent.

It is also possible to manually install integrations from a tarball file. For more information, see Install manually from a tarball archive.


Use the MSSQL integration's mssql-config.yml configuration file to put required login credentials and configure how data is collected. For an example configuration, see the example config file.


The mssql-config.yml file provides one command:

  • all_data: collects both inventory and metric data from the MS SQL Server environment.


The all_data command accepts the following arguments:

  • username: Username used to authenticate the MS SQL Server. This field is required.

  • password: Password used to authenticate the MS SQL Server. This field is required.

  • hostname: Hostname or IP of the MS SQL Server installation. Default:

  • port: Port number on which the MS SQL Server is listening. This is only required when instance is not specified.

  • instance: Instance the MS SQL Server is connected to. instance can be used in place of port by enabling SQL Browser; if enabled, do not include port in the argument.

  • enable_ssl: Indicates whether SSL is used to connect to the MS SQL Server. Default: false.

  • trust_server_certificate: If set to true, server certificate is not verified for SSL. If set to false, certificate will be verified against supplied certificate.

  • certificate_location: Certificate file to verify SSL encryption against.

  • timeout: Timeout for queries, in seconds. Default: 30.

  • enable_buffer_metrics: Enables the collection of buffer pool metrics. These can be resource intensive for large systems. Default: true.

  • custom_metrics_query: A SQL query with the required columns metric_name, metric_type, and metric_value. The metric_type can be gauge, rate, delta, or attribute. Additional columns collected with the query are added to the metric set as attributes.

If both port and instance are omitted, the default port of 1433 will be used.

Example mssql-config.yml file configuration:

Example configuration
integration_name: com.newrelic.mssql

  - name: mssql-server
    command: all_data
      hostname: mssql.localnet
      username: mssql_user
      password: mssql_password
      port: 1433
      # custom_metrics_query: >-
      #   SELECT 
      #     'instance_buffer_pool_size' AS metric_name,
      #     Count_big(*) * (8*1024) AS metric_value,
      #     'gauge' as metric_type,
      #     database_id
      #   FROM sys.dm_os_buffer_descriptors WITH (nolock)
      #   GROUP BY database_id
      env: production
      role: mssql

Find and use data

To find your integration data in Infrastructure, go to > Third-party services and select one of the MSSQL integration links.

In New Relic Insights, MSSQL data is attached to the following Insights event types:

For more on how to find and use your data, see Understand integration data.

Metric data

The MSSQL integration collects the following metric data attributes. Some metric name are prefixed with a category indicator and a period, such as asserts. or flush..

These attributes can be found by querying the MssqlDatabaseSample event types in Insights.

Metric Description


The size of the buffer pool per database.


Wait time of stall since last restart, in milliseconds.


Total number of times the transaction log for the database has been expanded since the last restart.


Available page file size, in bytes.


Total page file size, in bytes.

The MSSQL integration collects the following instance metrics. These attributes can be found by querying the MssqlInstanceSample event type in Insights.

Metric Description


The number of page splits per second.


The number of active connections.


The ratio of data pages found and read from the buffer cache over all data page requests.


The number of pages flushed to disk per second by a checkpoint or other operation that require all dirty pages to be flushed.


The number of batch requests per second on the buffer pool.


The life expectancy of a page in the buffer pool, in milliseconds.


The size of the buffer pool, in bytes.


The number of background processes on the instance.


The number of blocked processes on the instance.


The amount of disk space on the instance, in bytes.


The number of dormant processes on the instance.


The number of forced parameterizations per second on the instance.


The number of preconnect processes on the instance.


The number of runnable processes on the instance.


The number of runnable tasks on the instance.


The number of running processes on the instance.


The number of sleeping processes on the instance.


The number of suspended processes on the instance.


The number of transactions per second on the instance.


The available physical memory, in bytes.


The total physical memory, in bytes.


The percentage of memory utilization.


The number of user connections.


The number of lock requests per second that resulted in a deadlock since the last restart.


The number of kill connection errors per second since the last restart.


The number of times per second that MS SQL Server is unable to retain a lock right away for a resource.


The number of MS SQL compilations per second.


The number of MS SQL re-compilations per second.


The number of user errors per second since the last restart.


The percentage of buffer pools hits on the instance.


The number of milliseconds per second spent waiting across the instance.

These attributes can be found by querying the MssqlWaitSample event types in Insights.

Metric Description


Total wait time for this wait type, in milliseconds. This time is inclusive of signal_wait_time_ms.


The number of waits on this wait type, in milliseconds. This counter is incremented at the start of each wait.

Inventory data

The MSSQL integration captures the configuration parameters and current settings of the MS SQL Server environment. It collects the results of the sp_configure stored procedure, as well as current running configuration settings from the sys.configurations table.

The data is available on the Infrastructure Inventory page, under the config/mssql source. For more about inventory data, see Understand integration data.

For more help

Recommendations for learning more: