Monitor your SQL Server database performance with comprehensive metrics collected by the NRDOT Collector. By default, New Relic collects the metrics and query-level events referenced in the Default metrics and events section. You can enhance your monitoring by enabling your desired metrics listed in the Full-feature metrics section.
Default metrics and events
The following metrics are enabled by default. They are collected on any platform when the receiver is configured with a direct SQL Server connection.
Metric | Description |
|---|---|
| Number of batch requests received by SQL Server |
| Number of SQL compilations needed |
| Number of SQL recompilations needed |
| Number of lock requests resulting in a wait |
| Pages found in the buffer pool without having to read from disk |
| Time a page will stay in the buffer pool. This metric has the following available attribute: |
| Number of users connected to the SQL Server |
| The number of databases. This metric has the following available attribute: |
| Size of database files. This metric has the following available attributes: |
| Total number of deadlocks |
| The number of bytes of I/O on this file. This metric has the following available attributes: |
| Total time that the users waited for I/O issued on this file. This metric has the following available attributes: |
| The number of operations issued on the file. This metric has the following available attributes: |
| Total free space in temporary DB. This metric has the following available attribute: |
| TempDB version store size |
| Amount of memory used by the SQL Server memory pool. This metric has the following available attribute: |
| Total number of memory grants pending |
| Total wait time for this wait type. This metric has the following available attributes: |
| The number of processes that are currently blocked |
Log events
The following events are collected as OpenTelemetry log records and are enabled by default, except for db.server.procedure_definition which is opt-in. They provide query-level visibility: active query samples, top queries, execution plans, top stored procedures, and stored procedure definitions.
Per-session active query samples. Captures the current execution state of active SQL Server sessions at collection time. This event is enabled by default.
Use the query_sample_collection block to tune its behavior:
query_sample_collection: max_rows_per_query: 100 allowed_comment_keys: [nr_service_guid]Available parameters
Parameter | Description |
|---|---|
| The maximum number of rows returned by the sampling query. The default value is set to |
| Keys to extract from leading SQL comments for APM-DB correlation |
Attributes collected
Attribute name | Description |
|---|---|
| The text of the database query being executed |
| The database management system (DBMS) product as identified by the client instrumentation |
| The database name |
| Login name associated with the SQL Server session |
| Hostname or address of the client |
| TCP port used by the client |
| IP address of the peer client |
| TCP port used by the peer client |
| ID of the SQL Server session |
| Status of the session (for example, running, sleeping) |
| Timestamp when the session was established (login time), in ISO 8601 format |
| Total elapsed time in seconds since the session was established |
| Name of the client application that initiated the session |
| SQL command type being executed |
| Status of the request (for example, running, suspended) |
| CPU time consumed by the query, in seconds |
| Number of logical reads (data read from cache/memory) |
| Number of physical reads performed by the query |
| Number of writes performed by the query |
| Number of rows affected or returned by the query |
| Total elapsed time for completed executions of this plan, reported in delta seconds |
| Percentage of work completed |
| Estimated time remaining for the request to complete, in seconds |
| Type of wait encountered by the request. Empty if none |
| Duration in seconds the request has been waiting |
| The resource for which the session is waiting |
| SQL Server identifier for the locked or waited-on resource, if available |
| SQL Server type of the locked or waited-on resource, if available |
| Session ID that is blocking the current session. 0 if none |
| Timestamp of when the current blocking wait began, in ISO 8601 format |
| Deadlock priority value for the session |
| Lock timeout value in seconds |
| Number of transactions currently open in the session |
| Unique ID of the active transaction |
| Transaction isolation level used in the session, represented as a numeric constant |
| Binary hash value calculated on the query and used to identify queries with similar logic, reported in HEX format |
| Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in HEX format |
| Timestamp of when the SQL query started, in ISO 8601 format |
| Context information for the session, represented as a hexadecimal string |
| The SQL Server ID of the stored procedure, if any |
| The name of the stored procedure, if any |
| The full text of the SQL batch or stored procedure the statement was extracted from. Only populated when |
| New Relic service GUID extracted from the filtered query comments. Empty unless |
| MD5 hash of the normalized full SQL query text. Used for correlation with APM slow query traces. Only populated when |
Collection of event metrics for top N queries, filtered based on the highest elapsed time consumed in the collection interval. This event is enabled by default.
Use the top_query_collection block to tune its behavior:
top_query_collection: lookback_time: 60s max_query_sample_count: 1000 top_query_count: 250 collection_interval: 60s allowed_comment_keys: [nr_service_guid]Available parameters
Parameter | Description |
|---|---|
| The time window, in seconds, in which to query for top queries. Queries that finished execution outside the lookback window aren't included in the collection. Increasing this value helps capture long-running queries. The default value is 2 times the |
| The maximum number of records to fetch in a single run. The default value is set to |
| The maximum number of active queries to report in a single run. The default value is set to |
| The interval at which top queries are emitted by this receiver. This value only guarantees that top queries are collected at most once in this interval. The default value is set to |
| Keys to extract from leading SQL comments for APM-DB correlation |
Attributes collected
Attribute name | Description |
|---|---|
| The text of the database query being executed |
| The database management system (DBMS) product as identified by the client instrumentation |
| The database name |
| Number of times that the plan has been executed since it was last compiled, reported in delta value |
| Total amount of CPU time that was consumed by executions of this plan since it was compiled, reported in delta seconds |
| Total elapsed time for completed executions of this plan, reported in delta seconds |
| Total number of logical reads performed by executions of this plan since it was compiled, reported in delta value |
| Total number of logical writes performed by executions of this plan since it was compiled, reported in delta value |
| Total number of physical reads performed by executions of this plan since it was compiled, reported in delta value |
| Total number of rows returned by the query, reported in delta value |
| The total amount of reserved memory grant in KB this plan received since it was compiled, reported in delta value |
| Binary hash value calculated on the query and used to identify queries with similar logic, reported in HEX format |
| The query execution plan used by SQL Server |
| Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in HEX format |
| Timestamp of when the SQL query last started executing, in ISO 8601 format |
| Timestamp of when the SQL query execution plan was compiled, in ISO 8601 format |
| The SQL Server ID of the stored procedure, if any |
| The name of the stored procedure, if any |
| Number of times that the procedure has been executed since it was last compiled, reported in delta value |
| The full text of the SQL batch or stored procedure the statement was extracted from. Only populated when |
| New Relic service GUID extracted from the filtered query comments. Empty unless |
| MD5 hash of the normalized full SQL query text. Used for correlation with APM slow query traces. Only populated when |
The query execution plan. When enabled, the plan is reported here instead of on db.server.top_query, so an oversized plan payload can't drop the lightweight query statistics alongside it. This event is enabled by default.
Attribute name | Description |
|---|---|
| The database management system (DBMS) product as identified by the client instrumentation |
| The database name |
| Binary hash value calculated on the query and used to identify queries with similar logic, reported in HEX format |
| The query execution plan used by SQL Server |
| Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in HEX format |
Aggregated performance metrics for the top stored procedures by elapsed time, computed as deltas over the collection interval. Correlates with db.server.top_query and db.server.query_sample via sqlserver.procedure_id. This event is enabled by default.
Tip
Requires SQL Server 2017 CU3 or later, which introduced support for sys.dm_exec_procedure_stats.total_spills. On earlier versions, this event doesn't emit data and logs an error. Other events remain unaffected.
Use the top_procedure_collection block to tune its behavior:
top_procedure_collection: max_procedure_sample_count: 1000 top_procedure_count: 250 collection_interval: 60sAvailable parameters
Parameter | Description |
|---|---|
| How many procedures to read from |
| How many of those candidates to report, chosen by the elapsed time each procedure accrued since the previous run. Can't exceed |
| The interval at which top procedures are emitted by this receiver, independently of the global |
Attributes collected
Attribute name | Description |
|---|---|
| The database management system (DBMS) product as identified by the client instrumentation |
| The database name |
| The SQL Server ID of the stored procedure, if any |
| The name of the stored procedure, if any |
| The name of the database schema |
| Number of times that the procedure has been executed since it was last compiled, reported in delta value |
| Total amount of CPU time that was consumed by executions of this plan since it was compiled, reported in delta seconds |
| Total elapsed time for completed executions of this plan, reported in delta seconds |
| Total number of logical reads performed by executions of this plan since it was compiled, reported in delta value |
| Total number of logical writes performed by executions of this plan since it was compiled, reported in delta value |
| Total number of physical reads performed by executions of this plan since it was compiled, reported in delta value |
| Pages spilled to tempdb by the procedure over the collection interval, reported as a delta |
| Longest elapsed time for a single execution of the procedure, in seconds. Covers the whole period the plan has been cached, so unlike the other durations it isn't a delta |
| Shortest elapsed time for a single execution of the procedure, in seconds. Covers the whole period the plan has been cached, so unlike the other durations it isn't a delta |
| ISO 8601 timestamp of the last execution of the procedure |
The SQL source text of stored procedures observed in db.server.top_procedure. Correlates with db.server.top_procedure via sqlserver.procedure_id and db.namespace. This event collects nothing unless db.server.top_procedure is also enabled.
You can set the db.server.procedure_definition to true to enable procedure definition collection.
Tip
Requires the VIEW ANY DEFINITION permission. Without it, sqlserver.procedure_name can't be resolved and the row is skipped rather than reported with an error.
Attribute name | Description |
|---|---|
| The database management system (DBMS) product as identified by the client instrumentation |
| The database name |
| The SQL Server ID of the stored procedure, if any |
| The name of the stored procedure, if any |
| The SQL source text of the stored procedure as returned by |
Full-feature metrics
The full-feature configuration collects every default metric plus the following additional metrics. These metrics are organized by functionality and most require a direct SQL Server connection. You can set any of these metrics to true in the metrics section of your configuration to enable them.
Metric | Description |
|---|---|
| Number of SQL attentions (client cancellation interrupts) received per second |
| Number of SQL compilations per batch request |
| Number of page splits per batch request |
| Ratio of SQL recompilations to compilations, expressed as a percentage |
| Rate of auto-parameterization activity, broken down by result. This metric has the following available attribute: |
| Rate of plan executions, classified by plan guide result. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Total number of backups/restores |
| Number of execution errors |
| The number of unrestricted full table or index scans |
| Number of active transactions in the database. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Cluster type of the Always-On Availability Group. This metric has the following available attributes: |
| Failure condition level configured for the Availability Group (1-5). This metric has the following available attribute: |
| Health-check timeout configured for the Availability Group. This metric has the following available attribute: |
| Number of synchronized secondary replicas required to commit on the Availability Group. This metric has the following available attribute: |
| Size of the log-send or redo queue for an AG database replica. This metric has the following available attributes: |
| Redo rate for an AG database replica. This metric has the following available attributes: |
| Cumulative time spent in AG flow control, in milliseconds per second observed |
| Role of the availability replica. This metric has the following available attributes: |
| Synchronization health of the availability replica. This metric has the following available attributes: |
Metric | Description |
|---|---|
| Total number of index searches |
Metric | Description |
|---|---|
| Number of superlatches currently active |
| Rate of superlatch promotions or demotions. This metric has the following available attribute: |
| Number of latch waits per second |
| Average time spent waiting for latches (lighter-weight synchronization) |
| Total latch wait time |
Metric | Description |
|---|---|
| Total number of lock timeouts |
| Cumulative count of lock waits that occurred. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Total number of logins |
| Total number of logouts |
Metric | Description |
|---|---|
| Number of cache objects in the SQL Server cache. This metric has the following available attribute: |
| Number of pages in the SQL Server buffer pool. This metric has the following available attribute: |
| Total memory in use. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Computer uptime |
| Number of CPUs |
| Total disk space across volumes hosting SQL Server database files |
| Amount of system physical memory observed by SQL Server. This metric has the following available attribute: |
| Fraction of system physical memory in use by the SQL Server process |
| Total number of runnable tasks across online schedulers |
| Cumulative number of tasks that have waited on this wait type since SQL Server startup. This metric has the following available attributes: |
Metric | Description |
|---|---|
| Number of free list stalls |
| Total number of page lookups |
Metric | Description |
|---|---|
| Number of SQL Server processes (user sessions), broken down by status. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Throughput rate of replica data. This metric has the following available attribute: |
Metric | Description |
|---|---|
| The rate of operations issued. This metric has the following available attribute: |
| The number of read operations that were throttled in the last second |
| The number of write operations that were throttled in the last second |
Metric | Description |
|---|---|
| The number of tables. This metric has the following available attributes: |
Metric | Description |
|---|---|
| Cumulative wait time on tempdb allocation pages, broken down by page type. This metric has the following available attribute: |
| Number of tempdb pagelatch wait types with at least one active waiter |
| Number of tempdb data files configured on the instance |
| Size of each tempdb data or log file. This metric has the following available attributes: |
| Space used by tempdb, broken down by allocation category. This metric has the following available attribute: |
Metric | Description |
|---|---|
| Number of SQL Server tasks broken down by state. This metric has the following available attribute: |
| Number of SQL Server worker threads broken down by state. This metric has the following available attribute: |
| Maximum number of SQL Server worker threads configured on the instance |
| Fraction of configured SQL Server worker threads currently running |
Metric | Description |
|---|---|
| Time consumed in transaction delays |
| Age in seconds of the longest currently-open transaction on the server |
| Total number of mirror write transactions |
| Cumulative bytes cleaned from the tempdb version store |
| Cumulative bytes of row versions written to the tempdb version store |
Additional Windows metrics
The following metrics are available on Windows platforms when using the NRDOT Collector with SQL Server. These metrics provide Windows-specific performance insights for SQL Server monitoring.
Metric | Description |
|---|---|
| System uptime counter |
| Number of CPU cores available |
| Memory usage by SQL Server process. This metric has the following available attribute: |
| Percentage of pages found in the buffer cache |
| Ratio of cache hits to cache lookups. This metric has the following available attribute: |
| Number of SQL compilations per second |
| Number of user connections to SQL Server |
| Number of current locks. This metric has the following available attribute: |
| Number of lock timeouts per second |
| Total number of processes waiting for memory grants |
| Number of physical database page operations per second. This metric has the following available attribute: |
| Number of SQL recompilations per second |
| Number of transactions per second. This metric has the following available attribute: |
Amazon RDS limitations
When monitoring an Amazon RDS for SQL Server instance, certain metrics may report 0 or not be collected due to RDS service restrictions and SQL Server edition limitations.
Important
The following limitations apply specifically to SQL Server instances running on Amazon RDS. Self-hosted SQL Server deployments are not affected by these restrictions.
Metric | Limitation | Affected editions |
|---|---|---|
| Always reports | All editions |
| Not collected. Always On Availability Groups require Multi-AZ deployment, unavailable on Web and Express editions. | Web, Express |
| Emitted but always reports | Web, Express |
For more information, refer to Amazon RDS for SQL Server: Unsupported features and Multi-AZ for Amazon RDS for SQL Server.
Attribute glossary
The following table describes every verified attribute referenced in the metric descriptions above. A number of metrics in this file reference attributes (such as ag.cluster_type, lock_type, memory_type, replica.role, and others tied to Windows Performance Counter and failover-cluster metrics) that couldn't be verified against the upstream sqlserverreceiver documentation and aren't included here yet.
Attribute | Description | Values |
|---|---|---|
| Category to which this counter belongs | Any string |
| The current status of a database |
|
| The physical filename of the file being monitored | Any string |
| The logical filename of the file being monitored | Any string |
| The type of file being monitored | Any string |
| The direction of flow of bytes or operations |
|
| The tempdb space usage category. The values are mutually exclusive and partition total tempdb space |
|
| The functional area of SQL Server memory |
|
| Category of the reason for a wait | Any string |
| Type of the wait. Refer to Microsoft's WaitTypes documentation for more information | Any string |
| The result of an auto-parameterization attempt by the SQL Server query optimizer |
|
| Whether a SQL plan execution successfully used a matching plan guide ( |
|
| The direction of a superlatch transition |
|
| The name of the SQL Server Resource Governor workload group | Any string |
| The state of the cache objects |
|
| The type of page pool in the SQL Server buffer manager |
|
| The name of the SQL Server Resource Governor resource pool | Any string |
| The direction of flow of bytes for replica |
|
| The state of the table |
|
| The status of the table |
|
| Numeric identifier of the tempdb file | Any Int |
Azure SQL Database limitations
When monitoring Azure SQL Database, some metrics aren't available because the collector connects to a single database and doesn't have access to instance-level or operating system data.
Important
The following limitations apply only to Azure SQL Database. Azure SQL Managed Instance and self-hosted SQL Server support these metrics.
Metric | Limitation |
|---|---|
| Not supported on Azure SQL Database. These metrics require instance-level server properties. |
| Not supported on Azure SQL Database. These metrics require operating system views that the service doesn't expose. |
| Not supported on Azure SQL Database. |
| Not supported on Azure SQL Database. Instance-level tempdb views aren't available. |
| Not supported on Azure SQL Database. |
| Not supported on Azure SQL Database. Always On Availability Groups aren't exposed by the service. |
To avoid errors from unsupported queries, set these metrics to enabled: false in your receiver configuration. For setup steps, refer to Azure SQL Database instrumentation on Linux or Windows.
Related documentation
Linux instrumentation for self-hosted environments
Learn how to set up MSSQL monitoring in self-hosted Linux environments with New Relic.
Windows instrumentation for self-hosted environments
Learn how to set up MSSQL monitoring in self-hosted Windows environments with New Relic.
Set up APM-database correlation
Learn how to correlate your application performance with database operations in New Relic.