---
title: MSSQL NRDOT metrics reference
source: https://docs.newrelic.com/docs/opentelemetry/db360/mssql/metrics-reference
---

Monitor your SQL Server database performance with comprehensive metrics collected by the NRDOT Collector. By default, New Relic collects the metrics referenced in the [Available metrics](#default) section. You can enhance your monitoring by enabling your desired metrics listed in the [Additional metrics](#additional-metrics) section.

## Available metrics [#default]

The following metrics are collected automatically for New Relic UI functionality. These are enabled by default and work on any platform via a direct SQL Server connection.

**Default metrics**

| Metric                                   | Description                                                                                       | Unit               | Type           |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------ | -------------- |
| `sqlserver.batch.request.rate`           | Number of batch requests received by SQL Server                                                   | `{requests}/s`     | Gauge (double) |
| `sqlserver.batch.sql_compilation.rate`   | Number of SQL compilations needed                                                                 | `{compilations}/s` | Gauge (double) |
| `sqlserver.batch.sql_recompilation.rate` | Number of SQL recompilations needed                                                               | `{compilations}/s` | Gauge (double) |
| `sqlserver.lock.wait.rate`               | Number of lock requests resulting in a wait                                                       | `{requests}/s`     | Gauge (double) |
| `sqlserver.page.buffer_cache.hit_ratio`  | Pages found in the buffer pool without having to read from disk                                   | `%`                | Gauge (double) |
| `sqlserver.page.life_expectancy`         | Time a page will stay in the buffer pool. Available attributes: `performance_counter.object_name` | `s`                | Gauge (int)    |
| `sqlserver.user.connection.count`        | Number of users connected to the SQL Server                                                       | `{connections}`    | Gauge (int)    |

## Additional metrics [#additional-metrics]

The following metrics are disabled by default but can be enabled for deeper insights into SQL Server performance and health. These metrics are organized by functionality and most require a direct SQL Server connection.

**Batch / Compilation metrics**

| Metric                                    | Description                                                                                                                                                                       | Unit             | Type           |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------------- |
| `sqlserver.attention.rate`                | Number of SQL attentions (client cancellation interrupts) received per second                                                                                                     | `{attentions}/s` | Gauge (double) |
| `sqlserver.batch.compilation.utilization` | Number of SQL compilations per batch request                                                                                                                                      | `1`              | Gauge (double) |
| `sqlserver.batch.page_split.utilization`  | Number of page splits per batch request                                                                                                                                           | `1`              | Gauge (double) |
| `sqlserver.recompilation.ratio`           | Ratio of SQL recompilations to compilations, expressed as a percentage                                                                                                            | `%`              | Gauge (double) |
| `sqlserver.parameterization.rate`         | Rate of auto-parameterization activity, broken down by result. Available attributes: `sqlserver.parameterization.result` (`auto_attempted`, `safe`, `unsafe`, `failed`, `forced`) | `{params}/s`     | Gauge (double) |
| `sqlserver.plan.execution.rate`           | Rate of plan executions, classified by plan guide result. Available attributes: `sqlserver.plan.guidance.result` (`guided`, `misguided`)                                          | `{executions}/s` | Gauge (double) |

**Database general metrics**

| Metric                                      | Description                                                                                                                                      | Unit                      | Type           |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------- | -------------- |
| `sqlserver.database.backup_or_restore.rate` | Total number of backups/restores                                                                                                                 | `{backups_or_restores}/s` | Gauge (double) |
| `sqlserver.database.count`                  | The number of databases. Available attributes: `database.status` (`online`, `restoring`, `recovering`, `pending_recovery`, `suspect`, `offline`) | `{databases}`             | Gauge (int)    |
| `sqlserver.database.execution.errors`       | Number of execution errors                                                                                                                       | `{errors}`                | Gauge (int)    |
| `sqlserver.database.file.size`              | Size of database files. Available attributes: `file_type`, `db.namespace`                                                                        | `By`                      | Gauge (int)    |
| `sqlserver.database.full_scan.rate`         | The number of unrestricted full table or index scans                                                                                             | `{scans}/s`               | Gauge (double) |
| `sqlserver.database.transactions.active`    | Number of active transactions in the database. Available attributes: `db.namespace`                                                              | `{transactions}`          | Gauge (int)    |
| `sqlserver.deadlock.rate`                   | Total number of deadlocks                                                                                                                        | `{deadlocks}/s`           | Gauge (double) |

**Database / I/O & Latency metrics**

| Metric                          | Description                                                                                                                                           | Unit           | Type                     |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | ------------------------ |
| `sqlserver.database.io`         | The number of bytes of I/O on this file. Available attributes: `physical_filename`, `logical_filename`, `file_type`, `direction`                      | `By`           | Sum (cumulative, int)    |
| `sqlserver.database.latency`    | Total time that the users waited for I/O issued on this file. Available attributes: `physical_filename`, `logical_filename`, `file_type`, `direction` | `s`            | Sum (cumulative, double) |
| `sqlserver.database.operations` | The number of operations issued on the file. Available attributes: `physical_filename`, `logical_filename`, `file_type`, `direction`                  | `{operations}` | Sum (cumulative, int)    |

**Failover Cluster / Always-On Availability Groups metrics**

| Metric                                                      | Description                                                                                                                                                                                  | Unit            | Type           |
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------- |
| `sqlserver.failover_cluster.ag.cluster_type`                | Cluster type of the Always-On Availability Group. Available attributes: `ag.name`, `ag.cluster_type` (`wsfc`, `external`, `none`, `unknown`)                                                 | `1`             | Gauge (int)    |
| `sqlserver.failover_cluster.ag.failure_condition_level`     | Failure condition level configured for the Availability Group (1-5). Available attributes: `ag.name`                                                                                         | `1`             | Gauge (int)    |
| `sqlserver.failover_cluster.ag.health_check_timeout`        | Health-check timeout configured for the Availability Group. Available attributes: `ag.name`                                                                                                  | `ms`            | Gauge (int)    |
| `sqlserver.failover_cluster.ag.required_sync_secondaries`   | Number of synchronized secondary replicas required to commit on the Availability Group. Available attributes: `ag.name`                                                                      | `{secondaries}` | Gauge (int)    |
| `sqlserver.failover_cluster.replica.database.queue_size`    | Size of the log-send or redo queue for an AG database replica. Available attributes: `ag.name`, `replica.server_name`, `db.namespace`, `replica.queue_kind` (`log_send`, `redo`)             | `By`            | Gauge (int)    |
| `sqlserver.failover_cluster.replica.database.redo.rate`     | Redo rate for an AG database replica. Available attributes: `ag.name`, `replica.server_name`, `db.namespace`                                                                                 | `By/s`          | Gauge (double) |
| `sqlserver.failover_cluster.replica.flow_control_time`      | Cumulative time spent in AG flow control, in milliseconds per second observed                                                                                                                | `ms`            | Gauge (double) |
| `sqlserver.failover_cluster.replica.role`                   | Role of the availability replica. Available attributes: `ag.name`, `replica.server_name`, `replica.role` (`primary`, `secondary`, `resolving`, `unknown`)                                    | `1`             | Gauge (int)    |
| `sqlserver.failover_cluster.replica.synchronization_health` | Synchronization health of the availability replica. Available attributes: `ag.name`, `replica.server_name`, `replica.sync_health` (`healthy`, `partially_healthy`, `not_healthy`, `unknown`) | `1`             | Gauge (int)    |

**Index & Search metrics**

| Metric                        | Description                    | Unit           | Type           |
| ----------------------------- | ------------------------------ | -------------- | -------------- |
| `sqlserver.index.search.rate` | Total number of index searches | `{searches}/s` | Gauge (double) |

**Latch metrics**

| Metric                                       | Description                                                                                                        | Unit             | Type                     |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------- | ------------------------ |
| `sqlserver.latch.superlatch.count`           | Number of superlatches currently active                                                                            | `{superlatch}`   | Gauge (int)              |
| `sqlserver.latch.superlatch.transition.rate` | Rate of superlatch promotions or demotions. Available attributes: `transition.direction` (`promotion`, `demotion`) | `{transition}/s` | Gauge (double)           |
| `sqlserver.latch.wait.rate`                  | Number of latch waits per second                                                                                   | `{wait}/s`       | Gauge (double)           |
| `sqlserver.latch.wait_time.avg`              | Average time spent waiting for latches (lighter-weight synchronization)                                            | `s`              | Gauge (double)           |
| `sqlserver.latch.wait_time.total`            | Total latch wait time                                                                                              | `s`              | Sum (cumulative, double) |

**Locks (Detailed) metrics**

| Metric                        | Description                                                                                                       | Unit           | Type                  |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------- | -------------- | --------------------- |
| `sqlserver.lock.timeout.rate` | Total number of lock timeouts                                                                                     | `{timeouts}/s` | Gauge (double)        |
| `sqlserver.lock.wait.count`   | Cumulative count of lock waits that occurred. Available attributes: `workload_group.name` (`default`, `internal`) | `{wait}`       | Sum (cumulative, int) |

**Login / Logout metrics**

| Metric                  | Description             | Unit          | Type           |
| ----------------------- | ----------------------- | ------------- | -------------- |
| `sqlserver.login.rate`  | Total number of logins  | `{logins}/s`  | Gauge (double) |
| `sqlserver.logout.rate` | Total number of logouts | `{logouts}/s` | Gauge (double) |

**Memory metrics**

| Metric                                  | Description                                                                                                                                                                                | Unit       | Type                     |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- | ------------------------ |
| `sqlserver.memory.area`                 | Amount of memory used by the SQL Server memory pool. Available attributes: `memory.pool` (`target`, `total`, `sql_cache`, `optimizer`, `connection`, `granted_workspace`, `max_workspace`) | `By`       | Gauge (int)              |
| `sqlserver.memory.cache.object.count`   | Number of cache objects in the SQL Server cache. Available attributes: `cache.state` (`in_use`, `total`)                                                                                   | `{object}` | Gauge (int)              |
| `sqlserver.memory.grants.pending.count` | Total number of memory grants pending                                                                                                                                                      | `{grants}` | Sum (cumulative, int)    |
| `sqlserver.memory.page.count`           | Number of pages in the SQL Server buffer pool. Available attributes: `page.pool` (`cache`, `total`, `target`, `database`, `stolen`, `reserved`, `free`)                                    | `{page}`   | Gauge (int)              |
| `sqlserver.memory.usage`                | Total memory in use. Available attributes: `workload_group.name` (`default`, `internal`)                                                                                                   | `KB`       | Sum (cumulative, double) |

**OS-Level metrics**

| Metric                                        | Description                                                                                                                                | Unit        | Type                     |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------------------------ |
| `sqlserver.computer.uptime`                   | Computer uptime                                                                                                                            | `{seconds}` | Gauge (int)              |
| `sqlserver.cpu.count`                         | Number of CPUs                                                                                                                             | `{CPUs}`    | Gauge (int)              |
| `sqlserver.os.disk.size`                      | Total disk space across volumes hosting SQL Server database files                                                                          | `By`        | Gauge (int)              |
| `sqlserver.os.memory.usage`                   | Amount of system physical memory observed by SQL Server. Available attributes: `memory.state` (`available`, `total`)                       | `By`        | Gauge (int)              |
| `sqlserver.os.memory.utilization`             | Fraction of system physical memory in use by the SQL Server process                                                                        | `1`         | Gauge (double)           |
| `sqlserver.os.scheduler.runnable_tasks.count` | Total number of runnable tasks across online schedulers                                                                                    | `{tasks}`   | Gauge (int)              |
| `sqlserver.os.wait.duration`                  | Total wait time for this wait type. Available attributes: `wait.category`, `wait.type`                                                     | `s`         | Sum (cumulative, double) |
| `sqlserver.os.wait.tasks.count`               | Cumulative number of tasks that have waited on this wait type since SQL Server startup. Available attributes: `wait.category`, `wait.type` | `{tasks}`   | Sum (cumulative, int)    |

**Page Buffer (Detailed) metrics**

| Metric                                              | Description                  | Unit          | Type           |
| --------------------------------------------------- | ---------------------------- | ------------- | -------------- |
| `sqlserver.page.buffer_cache.free_list.stalls.rate` | Number of free list stalls   | `{stalls}/s`  | Gauge (int)    |
| `sqlserver.page.lookup.rate`                        | Total number of page lookups | `{lookups}/s` | Gauge (double) |

**Processes / Sessions metrics**

| Metric                        | Description                                                                                                                                                                                           | Unit          | Type        |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ----------- |
| `sqlserver.process.count`     | Number of SQL Server processes (user sessions), broken down by status. Available attributes: `process.status` (`background`, `dormant`, `preconnect`, `runnable`, `running`, `sleeping`, `suspended`) | `{processes}` | Gauge (int) |
| `sqlserver.processes.blocked` | The number of processes that are currently blocked                                                                                                                                                    | `{processes}` | Gauge (int) |

**Replica metrics**

| Metric                        | Description                                                                                        | Unit   | Type           |
| ----------------------------- | -------------------------------------------------------------------------------------------------- | ------ | -------------- |
| `sqlserver.replica.data.rate` | Throughput rate of replica data. Available attributes: `replica.direction` (`transmit`, `receive`) | `By/s` | Gauge (double) |

**Resource Pool / Throttling metrics**

| Metric                                              | Description                                                                        | Unit             | Type           |
| --------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------- | -------------- |
| `sqlserver.resource_pool.disk.operations`           | The rate of operations issued. Available attributes: `direction` (`read`, `write`) | `{operations}/s` | Gauge (double) |
| `sqlserver.resource_pool.disk.throttled.read.rate`  | The number of read operations that were throttled in the last second               | `{reads}/s`      | Gauge (int)    |
| `sqlserver.resource_pool.disk.throttled.write.rate` | The number of write operations that were throttled in the last second              | `{writes}/s`     | Gauge (double) |

**Tables metrics**

| Metric                  | Description                                                                                                                 | Unit       | Type                  |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------- | --------------------- |
| `sqlserver.table.count` | The number of tables. Available attributes: `table.state` (`active`, `inactive`), `table.status` (`temporary`, `permanent`) | `{tables}` | Sum (cumulative, int) |

**TempDB metrics**

| Metric                                         | Description                                                                                                                                                       | Unit        | Type                     |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------------------------ |
| `sqlserver.database.tempdb.space`              | Total free space in temporary DB. Available attributes: `tempdb.state` (`free`, `used`)                                                                           | `KB`        | Sum (cumulative, int)    |
| `sqlserver.database.tempdb.version_store.size` | TempDB version store size                                                                                                                                         | `KB`        | Gauge (double)           |
| `sqlserver.tempdb.allocation.wait_time.total`  | Cumulative wait time on tempdb allocation pages, broken down by page type. Available attributes: `allocation.page_type` (`gam`, `sgam`, `pfs`, `other`)           | `s`         | Sum (cumulative, double) |
| `sqlserver.tempdb.contention.waiters.count`    | Number of tempdb pagelatch wait types with at least one active waiter                                                                                             | `{waiters}` | Gauge (int)              |
| `sqlserver.tempdb.data_files.count`            | Number of tempdb data files configured on the instance                                                                                                            | `{files}`   | Gauge (int)              |
| `sqlserver.tempdb.file.size`                   | Size of each tempdb data or log file. Available attributes: `file_type`, `tempdb.file.id`                                                                         | `By`        | Gauge (int)              |
| `sqlserver.tempdb.space.usage`                 | Space used by tempdb, broken down by allocation category. Available attributes: `tempdb.space_kind` (`user_objects`, `internal_objects`, `version_store`, `free`) | `By`        | Gauge (int)              |

**Thread Pool metrics**

| Metric                                      | Description                                                                                                                         | Unit        | Type           |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------- |
| `sqlserver.thread_pool.tasks.count`         | Number of SQL Server tasks broken down by state. Available attributes: `task.state` (`current`, `queued`, `waiting_for_threadpool`) | `{tasks}`   | Gauge (int)    |
| `sqlserver.thread_pool.workers.count`       | Number of SQL Server worker threads broken down by state. Available attributes: `worker.state` (`running`, `suspended_or_sleeping`) | `{workers}` | Gauge (int)    |
| `sqlserver.thread_pool.workers.max`         | Maximum number of SQL Server worker threads configured on the instance                                                              | `{workers}` | Gauge (int)    |
| `sqlserver.thread_pool.workers.utilization` | Fraction of configured SQL Server worker threads currently running                                                                  | `1`         | Gauge (double) |

**Transactions (Detailed) metrics**

| Metric                                          | Description                                                            | Unit               | Type                     |
| ----------------------------------------------- | ---------------------------------------------------------------------- | ------------------ | ------------------------ |
| `sqlserver.transaction.delay`                   | Time consumed in transaction delays                                    | `ms`               | Sum (cumulative, double) |
| `sqlserver.transaction.longest_running_time`    | Age in seconds of the longest currently-open transaction on the server | `s`                | Gauge (double)           |
| `sqlserver.transaction.mirror_write.rate`       | Total number of mirror write transactions                              | `{transactions}/s` | Gauge (double)           |
| `sqlserver.transaction.version_cleanup.rate`    | Cumulative bytes cleaned from the tempdb version store                 | `By`               | Sum (cumulative, double) |
| `sqlserver.transaction.version_generation.rate` | Cumulative bytes of row versions written to the tempdb version store   | `By`               | Sum (cumulative, double) |

### Additional Windows metrics [#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.

**Additional Windows metrics**

| Metric                                               | Description                                                                               | Unit                 | Type           |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------------- | -------------------- | -------------- |
| `sqlserver.computer.uptime`                          | System uptime counter                                                                     | `s`                  | Gauge (double) |
| `sqlserver.cpu.count`                                | Number of CPU cores available                                                             | `{cpu}`              | Gauge (double) |
| `sqlserver.memory.usage`                             | Memory usage by SQL Server process. Available attributes: `memory_type`                   | `By`                 | Gauge (double) |
| `sqlserver.performance_counter.buffer.hit_ratio`     | Percentage of pages found in the buffer cache                                             | `%`                  | Gauge (double) |
| `sqlserver.performance_counter.cache.hit_ratio`      | Ratio of cache hits to cache lookups. Available attributes: `cache_type`                  | `%`                  | Gauge (double) |
| `sqlserver.performance_counter.compilations.rate`    | Number of SQL compilations per second                                                     | `{compilations}/s`   | Gauge (double) |
| `sqlserver.performance_counter.connections`          | Number of user connections to SQL Server                                                  | `{connections}`      | Gauge (double) |
| `sqlserver.performance_counter.locks.count`          | Number of current locks. Available attributes: `lock_type`                                | `{locks}`            | Gauge (double) |
| `sqlserver.performance_counter.locks.timeout.rate`   | Number of lock timeouts per second                                                        | `{timeouts}/s`       | Gauge (double) |
| `sqlserver.performance_counter.memory.grant_pending` | Total number of processes waiting for memory grants                                       | `{processes}`        | Gauge (double) |
| `sqlserver.performance_counter.page.operations.rate` | Number of physical database page operations per second. Available attributes: `page_type` | `{operations}/s`     | Gauge (double) |
| `sqlserver.performance_counter.recompilations.rate`  | Number of SQL recompilations per second                                                   | `{recompilations}/s` | Gauge (double) |
| `sqlserver.performance_counter.transactions.rate`    | Number of transactions per second. Available attributes: `database`                       | `{transactions}/s`   | Gauge (double) |

## Log events [#log-events]

The following events are collected as OpenTelemetry log records when enabled under the `events` section of your configuration. They provide query-level visibility: active query samples, top queries, execution plans, and top stored procedures.

**db.server.query_sample**

Per-session active query samples. Captures the current execution state of active SQL Server sessions at collection time.

| Attribute name                          | Description                                                                                                                                                                   |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `db.query.text`                         | The text of the database query being executed                                                                                                                                 |
| `db.system.name`                        | The database management system (DBMS) product as identified by the client instrumentation                                                                                     |
| `db.namespace`                          | The database name                                                                                                                                                             |
| `user.name`                             | Login name associated with the SQL Server session                                                                                                                             |
| `client.address`                        | Hostname or address of the client                                                                                                                                             |
| `client.port`                           | TCP port used by the client                                                                                                                                                   |
| `network.peer.address`                  | IP address of the peer client                                                                                                                                                 |
| `network.peer.port`                     | TCP port used by the peer client                                                                                                                                              |
| `sqlserver.session_id`                  | ID of the SQL Server session                                                                                                                                                  |
| `sqlserver.session_status`              | Status of the session (for example, running, sleeping)                                                                                                                        |
| `sqlserver.session.start_time`          | Timestamp when the session was established (login time), in ISO 8601 format                                                                                                   |
| `sqlserver.session.duration`            | Total elapsed time in seconds since the session was established                                                                                                               |
| `sqlserver.client.app.name`             | Name of the client application that initiated the session                                                                                                                     |
| `sqlserver.command`                     | SQL command type being executed                                                                                                                                               |
| `sqlserver.request_status`              | Status of the request (for example, running, suspended)                                                                                                                       |
| `sqlserver.cpu_time`                    | CPU time consumed by the query, in seconds                                                                                                                                    |
| `sqlserver.logical_reads`               | Number of logical reads (data read from cache/memory)                                                                                                                         |
| `sqlserver.reads`                       | Number of physical reads performed by the query                                                                                                                               |
| `sqlserver.writes`                      | Number of writes performed by the query                                                                                                                                       |
| `sqlserver.row_count`                   | Number of rows affected or returned by the query                                                                                                                              |
| `sqlserver.total_elapsed_time`          | Total elapsed time for completed executions of this plan, reported in delta seconds                                                                                           |
| `sqlserver.percent_complete`            | Percentage of work completed                                                                                                                                                  |
| `sqlserver.estimated_completion_time`   | Estimated time remaining for the request to complete, in seconds                                                                                                              |
| `sqlserver.wait_type`                   | Type of wait encountered by the request. Empty if none                                                                                                                        |
| `sqlserver.wait_time`                   | Duration in seconds the request has been waiting                                                                                                                              |
| `sqlserver.wait_resource`               | The resource for which the session is waiting                                                                                                                                 |
| `sqlserver.wait.resource.id`            | SQL Server identifier for the locked or waited-on resource, if available                                                                                                      |
| `sqlserver.wait.resource.type`          | SQL Server type of the locked or waited-on resource, if available                                                                                                             |
| `sqlserver.blocking_session_id`         | Session ID that is blocking the current session. 0 if none                                                                                                                    |
| `sqlserver.blocking.start_time`         | Timestamp of when the current blocking wait began, in ISO 8601 format                                                                                                         |
| `sqlserver.deadlock_priority`           | Deadlock priority value for the session                                                                                                                                       |
| `sqlserver.lock_timeout`                | Lock timeout value in seconds                                                                                                                                                 |
| `sqlserver.open_transaction_count`      | Number of transactions currently open in the session                                                                                                                          |
| `sqlserver.transaction_id`              | Unique ID of the active transaction                                                                                                                                           |
| `sqlserver.transaction_isolation_level` | Transaction isolation level used in the session, represented as a numeric constant                                                                                            |
| `sqlserver.query_hash`                  | Binary hash value calculated on the query and used to identify queries with similar logic, reported in HEX format                                                             |
| `sqlserver.query_plan_hash`             | Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in HEX format                                           |
| `sqlserver.query_start`                 | Timestamp of when the SQL query started, in ISO 8601 format                                                                                                                   |
| `sqlserver.context_info`                | Context information for the session, represented as a hexadecimal string                                                                                                      |
| `sqlserver.procedure_id`                | The SQL Server ID of the stored procedure, if any                                                                                                                             |
| `sqlserver.procedure_name`              | The name of the stored procedure, if any                                                                                                                                      |
| `db.query.full_text`                    | The full text of the SQL batch or stored procedure the statement was extracted from. Only populated when `collect_full_query_text` is enabled                                 |
| `db.query.comment_tags.nr_service_guid` | New Relic service GUID extracted from the filtered query comments. Empty unless `nr_service_guid` is included in `allowed_comment_keys`. Used for correlation with APM traces |
| `db.query.text.normalized.hash`         | MD5 hash of the normalized full SQL query text. Used for correlation with APM slow query traces. Only populated when `collect_full_query_text` is enabled                     |

**db.server.top_query**

Collection of event metrics for top N queries, filtered based on the highest elapsed time consumed in the collection interval.

| Attribute name                          | Description                                                                                                                                                                   |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `db.query.text`                         | The text of the database query being executed                                                                                                                                 |
| `db.system.name`                        | The database management system (DBMS) product as identified by the client instrumentation                                                                                     |
| `db.namespace`                          | The database name                                                                                                                                                             |
| `sqlserver.execution_count`             | Number of times that the plan has been executed since it was last compiled, reported in delta value                                                                           |
| `sqlserver.total_worker_time`           | Total amount of CPU time that was consumed by executions of this plan since it was compiled, reported in delta seconds                                                        |
| `sqlserver.total_elapsed_time`          | Total elapsed time for completed executions of this plan, reported in delta seconds                                                                                           |
| `sqlserver.total_logical_reads`         | Total number of logical reads performed by executions of this plan since it was compiled, reported in delta value                                                             |
| `sqlserver.total_logical_writes`        | Total number of logical writes performed by executions of this plan since it was compiled, reported in delta value                                                            |
| `sqlserver.total_physical_reads`        | Total number of physical reads performed by executions of this plan since it was compiled, reported in delta value                                                            |
| `sqlserver.total_rows`                  | Total number of rows returned by the query, reported in delta value                                                                                                           |
| `sqlserver.total_grant_kb`              | The total amount of reserved memory grant in KB this plan received since it was compiled, reported in delta value                                                             |
| `sqlserver.query_hash`                  | Binary hash value calculated on the query and used to identify queries with similar logic, reported in HEX format                                                             |
| `sqlserver.query_plan`                  | The query execution plan used by SQL Server                                                                                                                                   |
| `sqlserver.query_plan_hash`             | Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in HEX format                                           |
| `sqlserver.query.last_started`          | Timestamp of when the SQL query last started executing, in ISO 8601 format                                                                                                    |
| `sqlserver.query.plan.creation_time`    | Timestamp of when the SQL query execution plan was compiled, in ISO 8601 format                                                                                               |
| `sqlserver.procedure_id`                | The SQL Server ID of the stored procedure, if any                                                                                                                             |
| `sqlserver.procedure_name`              | The name of the stored procedure, if any                                                                                                                                      |
| `sqlserver.procedure_execution_count`   | Number of times that the procedure has been executed since it was last compiled, reported in delta value                                                                      |
| `db.query.full_text`                    | The full text of the SQL batch or stored procedure the statement was extracted from. Only populated when `collect_full_query_text` is enabled                                 |
| `db.query.comment_tags.nr_service_guid` | New Relic service GUID extracted from the filtered query comments. Empty unless `nr_service_guid` is included in `allowed_comment_keys`. Used for correlation with APM traces |
| `db.query.text.normalized.hash`         | MD5 hash of the normalized full SQL query text. Used for correlation with APM slow query traces. Only populated when `collect_full_query_text` is enabled                     |

**db.server.query_plan**

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.

| Attribute name              | Description                                                                                                                         |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `db.system.name`            | The database management system (DBMS) product as identified by the client instrumentation                                           |
| `db.namespace`              | The database name                                                                                                                   |
| `sqlserver.query_hash`      | Binary hash value calculated on the query and used to identify queries with similar logic, reported in HEX format                   |
| `sqlserver.query_plan`      | The query execution plan used by SQL Server                                                                                         |
| `sqlserver.query_plan_hash` | Binary hash value calculated on the query execution plan and used to identify similar query execution plans, reported in HEX format |

**db.server.top_procedure**

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`.

> #### 💡 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.

| Attribute name                             | Description                                                                                                                                                                 |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `db.system.name`                           | The database management system (DBMS) product as identified by the client instrumentation                                                                                   |
| `db.namespace`                             | The database name                                                                                                                                                           |
| `sqlserver.procedure_id`                   | The SQL Server ID of the stored procedure, if any                                                                                                                           |
| `sqlserver.procedure_name`                 | The name of the stored procedure, if any                                                                                                                                    |
| `sqlserver.schema.name`                    | The name of the database schema                                                                                                                                             |
| `sqlserver.procedure_execution_count`      | Number of times that the procedure has been executed since it was last compiled, reported in delta value                                                                    |
| `sqlserver.total_worker_time`              | Total amount of CPU time that was consumed by executions of this plan since it was compiled, reported in delta seconds                                                      |
| `sqlserver.total_elapsed_time`             | Total elapsed time for completed executions of this plan, reported in delta seconds                                                                                         |
| `sqlserver.total_logical_reads`            | Total number of logical reads performed by executions of this plan since it was compiled, reported in delta value                                                           |
| `sqlserver.total_logical_writes`           | Total number of logical writes performed by executions of this plan since it was compiled, reported in delta value                                                          |
| `sqlserver.total_physical_reads`           | Total number of physical reads performed by executions of this plan since it was compiled, reported in delta value                                                          |
| `sqlserver.procedure.tempdb.spilled_pages` | Pages spilled to tempdb by the procedure over the collection interval, reported as a delta                                                                                  |
| `sqlserver.procedure.max_duration`         | 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  |
| `sqlserver.procedure.min_duration`         | 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 |
| `sqlserver.procedure.last_execution_time`  | ISO 8601 timestamp of the last execution of the procedure                                                                                                                   |

## Amazon RDS limitations [#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.

**RDS metric limitations reference**

| Metric                                                                                                                                                                                                                                                                                                                                                                                                                                            | Limitation                                                                                                                    | Affected editions |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| `sqlserver.database.execution.errors`                                                                                                                                                                                                                                                                                                                                                                                                             | Always reports `0`. SQL Server ML Services (Extensibility Framework) is not provisioned on any Amazon RDS SQL Server edition. | All editions      |
| `sqlserver.failover_cluster.ag.cluster_type`, `sqlserver.failover_cluster.ag.failure_condition_level`, `sqlserver.failover_cluster.ag.health_check_timeout`, `sqlserver.failover_cluster.ag.required_sync_secondaries`, `sqlserver.failover_cluster.replica.database.queue_size`, `sqlserver.failover_cluster.replica.database.redo.rate`, `sqlserver.failover_cluster.replica.role`, `sqlserver.failover_cluster.replica.synchronization_health` | Not collected. Always On Availability Groups require Multi-AZ deployment, unavailable on Web and Express editions.            | Web, Express      |
| `sqlserver.failover_cluster.replica.flow_control_time`, `sqlserver.replica.data.rate`, `sqlserver.transaction.delay`, `sqlserver.transaction.mirror_write.rate`                                                                                                                                                                                                                                                                                   | Emitted but always reports `0`. These measure AG replica activity unavailable without Multi-AZ.                               | Web, Express      |

For more information, refer to [Amazon RDS for SQL Server: Unsupported features](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/SQLServer.Concepts.General.FeatureNonSupport.html) and [Multi-AZ for Amazon RDS for SQL Server](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_SQLServerMultiAZ.html).

## Related documentation [#related-docs]

[Linux instrumentation for self-hosted environments](https://docs.newrelic.com/docs/opentelemetry/db360/mssql/linux-hosted)

Learn how to set up MSSQL monitoring in self-hosted Linux environments with New Relic.

[Windows instrumentation for self-hosted environments](https://docs.newrelic.com/docs/opentelemetry/db360/mssql/windows-hosted-sql)

Learn how to set up MSSQL monitoring in self-hosted Windows environments with New Relic.

[Set up APM-database correlation](https://docs.newrelic.com/docs/opentelemetry/db360/capabilities/db-apm)

Learn how to correlate your application performance with database operations in New Relic.
