Improve the health and performance monitoring of your Microsoft SQL Servers.
Monitor Microsoft SQL Server health and performance with Dynatrace extension.
Microsoft SQL Server database monitoring is based on a remote monitoring approach implemented as a Dynatrace ActiveGate extension. The extension queries MS SQL databases for key performance and health metrics, extending your visibility, and allowing Dynatrace Intelligence to provide anomaly detection and problem analysis.
Supported on:
Views and tables involved:
Supported on:
Views and tables involved:
Supported on:
Views and tables involved:
Supported on:
Views and tables involved:
Monitor query performance stats
Supported on:
Involved views and tables:
Monitor top longest queries
Supported on:
Involved views and tables:
Supported on:
Involved views and tables:
Supported on:
Involved views and tables:
Supported on:
Involved views and tables:
Monitor the age of the latest backup and individual backups per database
Supported on:
Involved views and tables:
Monitor backup file size per database
Supported on:
Involved views and tables:
Monitoring individual Azure SQL Database backups
Supported on:
Involved views and tables:
Monitor database file stats
Supported on:
Involved views and tables:
Monitoring the largest database files on Azure SQL Database
Supported on:
Involved views and tables:
Monitoring the largest database files on other SQL Server types
Supported on:
Involved views and tables:
Supported on:
Involved views and tables:
Supported on:
Involved views and tables:
Required permissions:
VIEW SERVER PERFORMANCE STATE permission.VIEW SERVER STATE permission.##MS_ServerStateReader## server role.VIEW DATABASE STATE permission on the database; or##MS_ServerStateReader## server role.VIEW SERVER STATE permission.VIEW SERVER PERFORMANCE STATE permission.VIEW SERVER STATE permission.##MS_ServerStateReader## server role.VIEW DATABASE STATE permission on the database; or##MS_ServerStateReader## server role.VIEW SERVER STATE permission.master database for all databases to be visible.master database are visible.ONLINE databases:
VIEW ANY DATABASE (default permission for the public role)OFFLINE databases as well:
ALTER ANY DATABASE on server level; orCREATE DATABASE permission in the master database.VIEW DATABASE STATE permission.VIEW DATABASE STATE permission.VIEW DATABASE STATE permission.VIEW DATABASE STATE permission.VIEW DATABASE STATE permission.VIEW SERVER PERFORMANCE STATE permission.VIEW SERVER STATE permission.VIEW ANY DEFINITION; orCREATE DATABASE; orALTER ANY DATABASE.VIEW ANY DEFINITION permission.VIEW ANY DEFINITION permission.VIEW ANY DATABASE; orALTER ANY DATABASE; orCREATE DATABASE permission in master is required.VIEW SERVER PERFORMANCE STATE permission.VIEW SERVER STATE permission.VIEW SERVER PERFORMANCE STATE permission.VIEW SERVER STATE permission.VIEW SERVER PERFORMANCE STATE permission.VIEW SERVER STATE permission.##MS_ServerStateReader## server role.VIEW DATABASE STATE permission on the database; or##MS_ServerStateReader## server role.The extension is reported to work with other types of SQL Server, such as AWS RDS or SQL Server on Linux, but they're not officially supported.
Other types of replication and HA monitoring, including the publisher/subscriber model, are not supported yet.
This extension supports any version of SQL Server with active extended support by Microsoft. See the official Microsoft documentation about lifecycle dates for SQL Server.
Follow these steps to configure your device for Microsoft SQL Server database monitoring.
Go to Dynatrace Hub
.
Select and install Microsoft SQL Server extension. This enables the extension in your monitoring environment.
Select Add DB Instance in the
Databases. This opens the Add DB Instance wizard.
Select Microsoft SQL Server section in the wizard.
Select a hosting type from the options. This choice determines which script generates the necessary database objects later in the process.
Set up the connection to your database instance. Provide the required credentials directly in the wizard or use secure alternatives:
dynatrace monitoring user you have created directly or use secure alternatives.
You can enable log monitoring to activate extension status logs. It allows monitoring of the longest running queries and the largest database files.
v2.7.0:
v2.0.0:
instance dimension now only contains the name of the actual named instance or MSSQLSERVER by default.hoursSinceBackup metric is removed and replaced by sql-server.databases.backup.age.v1.2.0:
There is no charge to use the extension. You are only charged for the data that the extension ingests.
The Microsoft SQL Server extension ingests custom metrics, which consume Davis Data Units (DDUs) (Dynatrace classic license) or Metrics powered by Grail (DPS), according to your license model.
Each enabled feature set increases consumption. The default feature set cannot be turned off.
The number of metric data points produced per minute for a given metric is calculated as follows:
number of unique associated entities / minutes between retrievals = metric data points per minute
Example:
sql-server.databases.backup.size2 instances with 20 databases in each.2 (SQL Server Instances) * 20 (SQL Server Databases in each) = 40 unique databases in total.40 / 1 = 40.In the Dynatrace Platform Subscription, metric ingestion consumes Metrics powered by Grail according to the number of ingested metric data points.
To calculate the approximate yearly consumption, apply the following calculation: <metric data points per minute> * 60 minutes * 24 hours * 365 days.
For the example above: 40 * 60 * 24 * 365 = 21,024,000 metric data points per year.
In the classic licensing model, metric ingestion consumes Davis Data Units (DDUs) at the rate of .001 DDUs per metric data point. Multiply the above formula for annual data points by .001 to estimate annual DDU usage.
For the example above: 40 * 60 * 24 * 365 * 0.001 = 21,024 DDUs per year.
The DDU cost above does not include any possible log events or custom events that are triggered by the extension. For more information, see DDU events.
You can enable a collection of top queries ordered by total duration using the Queries feature set.
Top queries are fetched by the extension every 5 minutes.
The following query, when executed in Logs and Events, displays top queries as observed within the most recent 5-minute timeframe using DQL:
fetch logs, from:now()-60m| filter matchesValue(dt.extension.name, "com.dynatrace.extension.sql-server")| filter matchesValue(event.group, "longest_queries")| fields total_duration, avg_duration, content, server, instance, num_executions, query_plan| sort asDouble(total_duration) desc
Description of fields:
total_duration field represents a sum of all executions of this query over the given 5-minute timeframe in seconds.avg_duration represents the average execution time of this query of the given 5-minute timeframe in seconds.content field contains the SQL text of the query.On Managed tenants: log records can be retrieved by filtering logs using two attributes:
dt.extension.name: com.dynatrace.extension.sql-server; andevent.group: longest_queries.You can enable collection of the largest database files by size using the Database files feature set.
Top database files by size are fetched by the extension every 5 minutes.
The following query, when executed in Logs and Events, displays the largest database files as observed within the most recent 5-minute timeframe by size using DQL:
fetch logs, from:now()-5m| filter matchesValue(dt.extension.name, "com.dynatrace.extension.sql-server")| filter matchesValue(event.group, "largest_files")| fields content, file_size, file_type_desc, file_state_desc, database, server, instance, file_used_space, file_empty_space| sort asDouble(file_size) desc
Description of fields:
content field represents the physical name of the file as handled by the host OS.file_size is reported in KB.file_used_space is reported in KB and represents the amount of space occupied by allocated pages within a specific file.file_empty_space is reported in KB and represents the amount of space that is still empty within a specific file.On Managed tenants: log records can be retrieved by filtering logs using two attributes:
dt.extension.name: com.dynatrace.extension.sql-server; andevent.group: largest_files.You can enable monitoring of current jobs using the Jobs feature set.
Current jobs are fetched by the extension every 5 minutes.
The following query, when executed in Logs and Events, displays current jobs as observed within the most recent 5-minute timeframe using DQL:
fetch logs, from:now()-5m| filter matchesValue(dt.extension.name, "com.dynatrace.extension.sql-server")| filter matchesValue(event.group, "current_jobs")| fields job_name, job_status, content, enabled, last_run_outcome, duration, instance, server, start_execution_date, stop_execution_date, job_category, category_name| sort asDouble(duration) desc
Description of fields:
content field represents the last execution outcome message.job_status and last_run_outcome are identical, except for two situations:
job_status equals Idle.job_status equals In Progress.duration represents complete job duration in seconds after execution is finished.category_id represents the category id of the job.category_name represents the Name assigned to the category id.On Managed tenants: log records can be retrieved by filtering logs using 2 attributes
dt.extension.name: com.dynatrace.extension.sql-server; andevent.group: current_jobs.Monitoring of failed jobs can be enabled using the Jobs feature set.
Failed jobs are fetched by extension every 5 minutes.
The query below, when executed in Logs and Events, displays failed jobs, as observed within the most recent 5-minute timeframe, using DQL:
fetch logs, from:now()-5m| filter matchesValue(dt.extension.name, "com.dynatrace.extension.sql-server")| filter matchesValue(event.group, "failed_jobs")| fields job_name, step_name, outcome, content, duration, instance, server, sql_severity, retries_attempted, start_execution_date, stop_execution_date| sort stop_execution_date desc
Description of fields:
content field represents the message of the last executed step and usually contains the error.outcome represents the final job status message as composed by SQL Server Agent.duration represents the complete job duration in seconds after execution is finished.On Managed tenants: log records can be retrieved by filtering logs using two attributes:
dt.extension.name: com.dynatrace.extension.sql-server; andevent.group: failed_jobs.sql-server.memory.target
number of SQL Server Instances in environment * 60sql-server.memory.physical
number of SQL Server Instances in environment * 60sql-server.databases.state
number of SQL Server Databases in environment * 60sql-server.uptime
number of SQL Server Instances in environment * 12sql-server.databases.transactions.count
number of SQL Server Databases in environment * 60sql-server.memory.total
number of SQL Server Instances in environment * 60sql-server.cpu.kernelTime.count
number of SQL Server Instances in environment * 60sql-server.general.userConnections
number of SQL Server Instances in environment * 60sql-server.general.processesBlocked
number of SQL Server Instances in environment * 60sql-server.general.logins.count
number of SQL Server Instances in environment * 60sql-server.cpu.userTime.count
number of SQL Server Instances in environment * 60sql-server.memory.virtual
number of SQL Server Instances in environment * 60sql-server.host.cpus
number of SQL Server Hosts in environment * 12sql-server.worker.activeWorkers
number of SQL Server Instances in environment * 60sql-server.worker.maxWorkers
number of SQL Server Instances in environment * 60sql-server.worker.threadsPercent
number of SQL Server Instances in environment * 60sql-server.always-on.ag.secondaryRecoveryHealth
number of SQL Server Availability Groups in environment * 60sql-server.always-on.ag.primaryRecoveryHealth
number of SQL Server Availability Groups in environment * 60sql-server.always-on.ar.failoverMode
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.ag.synchronizationHealth
number of SQL Server Availability Groups in environment * 60sql-server.always-on.ar.operationalState
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.ar.connectedState
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.db.filestreamSendRate
number of SQL Server Availability Databases in environment * 60sql-server.always-on.db.state
number of SQL Server Availability Databases in environment * 60sql-server.always-on.db.synchronizationHealth
number of SQL Server Availability Databases in environment * 60sql-server.always-on.db.logSendQueueSize
number of SQL Server Availability Databases in environment * 60sql-server.always-on.ar.role
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.db.synchronizationState
number of SQL Server Availability Databases in environment * 60sql-server.always-on.db.redoRate
number of SQL Server Availability Databases in environment * 60sql-server.always-on.db.redoQueueSize
number of SQL Server Availability Databases in environment * 60sql-server.always-on.ar.synchronizationHealth
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.db.logSendRate
number of SQL Server Availability Databases in environment * 60sql-server.always-on.ar.availabilityMode
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.ag.automatedBackupPreference
number of SQL Server Availability Groups in environment * 60sql-server.always-on.ar.isLocal
number of SQL Server Availability Replicas in environment * 60sql-server.always-on.ar.recoveryHealth
number of SQL Server Availability Replicas in environment * 60sql-server.databases.backup.age
number of SQL Server Databases in environment * 60sql-server.databases.backup.size
number of SQL Server Databases in environment * 60sql-server.databases.file.emptySpace
number of SQL Server Databases in environment * 60sql-server.databases.file.size
number of SQL Server Databases in environment * 60sql-server.databases.file.usedSpace
number of SQL Server Databases in environment * 60largest_files
Up to 100 (num of files) * 12 * avg log sizesql-server.latches.waits.count
number of SQL Server Instances in environment * 60sql-server.latches.averageWaitTime.count
number of SQL Server Instances in environment * 60sql-server.locks.timeouts.count
number of SQL Server Instances in environment * 60sql-server.locks.waits.count
number of SQL Server Instances in environment * 60sql-server.locks.waitTime.count
number of SQL Server Instances in environment * 60sql-server.locks.deadlocks.count
number of SQL Server Instances in environment * 60sql-server.buffers.checkpointPages.count
number of SQL Server Instances in environment * 60sql-server.memory.grantsOutstanding
number of SQL Server Instances in environment * 60sql-server.memory.connection
number of SQL Server Instances in environment * 60sql-server.buffers.pageWrites.count
number of SQL Server Instances in environment * 60sql-server.buffers.pageLifeExpectancy
number of SQL Server Instances in environment * 60sql-server.memory.grantsPending
number of SQL Server Instances in environment * 60sql-server.buffers.cacheHitRatio
number of SQL Server Instances in environment * 60sql-server.buffers.freeListStalls.count
number of SQL Server Instances in environment * 60sql-server.buffers.pageReads.count
number of SQL Server Instances in environment * 60sql-server.sql.recompilations.count
number of SQL Server Instances in environment * 60sql-server.sql.compilations.count
number of SQL Server Instances in environment * 60sql-server.sql.batchRequests.count
number of SQL Server Instances in environment * 60sql-server.locks.elapsedTimeRequestsPercent
number of SQL Server Instances in environment * 60sql-server.databases.failedDistributedTransactions.count
number of SQL Server Databases in environment * 60sql-server.locks.byWaitType
number of SQL Server Instances in environment * 60longest_queries
Up to 100 (num of queries) * 12 * avg log sizeinstance_locks_wait_time_type
number of SQL Server Instances in environment * 60sql-server.replica.bytesSentToTransport.count
number of SQL Server Instances in environment * 60sql-server.replica.sends.count
number of SQL Server Instances in environment * 60sql-server.replica.sendsToTransport.count
number of SQL Server Instances in environment * 60sql-server.replica.bytesReceived.count
number of SQL Server Instances in environment * 60sql-server.replica.bytesSent.count
number of SQL Server Instances in environment * 60sql-server.replica.resentMessages.count
number of SQL Server Instances in environment * 60sql-server.replica.receives.count
number of SQL Server Instances in environment * 60sql-server.sessions
number of SQL Server Instances in environment * 60sql-server.databases.log.flushWaits.count
number of SQL Server Databases in environment * 60sql-server.databases.log.filesUsedSize
number of SQL Server Databases in environment * 60sql-server.databases.log.growths.count
number of SQL Server Databases in environment * 60sql-server.databases.log.truncations.count
number of SQL Server Databases in environment * 60sql-server.databases.log.shrinks.count
number of SQL Server Databases in environment * 60sql-server.databases.log.filesSize
number of SQL Server Databases in environment * 60sql-server.databases.log.percentUsed
number of SQL Server Databases in environment * 60sql-server.sql.agent.status
number of SQL Server Agents in environment * 60current_jobs
Number of currently enabled jobs * 12 * avg log sizefailed_jobs
top 100 failed jobs * 12 * avg log sizeall_requests
avg Number of active requests * 60 * avg log sizenote on current_jobs, failed_jobs, longest_queries, all_requests, and largest_files: These metrics are based on Log data. As every environment is different, the calculation needs to be estimated on the client side. Then calculate the data size ingested. Currently, 100 DDUs are consumed per GB ingested. See the DDU consumption model for Log Management and Analytics in the documentation. If you're on Log Monitoring Classic, each log record (line, message, entry) deducts 0.005 DDU from your available quota. See the DDUs for Log Monitoring Classic in the documentation.
The two metrics below
sql-server.databases.file.usedSpacesql-server.databases.file.emptySpaceare only reported for the database the extension is currently connected to. This is due to sys.allocation_units only containing information about used pages of the database that are currently used inside the connection.
master database (limitation of SQL Server itself).Azure backups are monitored by querying the sys.db_database_backups view, which is currently available for all Azure SQL Database service tiers except Hyperscaler.
To obtain information about every replica in a given availability group, connect the extension to the server instance that is hosting the primary replica. When connected to a server instance that is hosting a secondary replica of an availability group, the extension returns only local information for the availability group.
When connected to a secondary replica, the extension retrieves the states of every secondary database on the server instance. On the primary replica, the extension returns data for each primary database and for the corresponding secondary database.
Depending on the action and higher-level states, database-state information may be unavailable or out of date. Furthermore, the values have only local relevance. See limitations of sys.dm_hadr_database_replica_states.
When a database is added to an availability group, the primary database is automatically joined to the group. Secondary databases must be manually prepared on each secondary replica before they can be joined to the availability group.
If the local server instance cannot communicate with the WSFC failover cluster (for example, because the cluster is down or quorum has been lost), only rows for local availability replicas are returned. These rows contain only the columns of data that are cached locally in metadata.
SELECT queries to obtain monitoring data. The database is never modified or locked.sys.* system views and msdb database (when applicable). User databases and objects are never affected.query interval and heavy query interval, have been added. If you want the 1-minute queries to run at intervals greater than 1 minute. For example, every 10 minutes, you can enter the number 10 in this box.heavy query interval input box functions the same. Except you're changing the frequency of queries that run every 5 minutes.Locks and waits feature set. If you're on SaaS, you'll have a new Dashboard to view this data in an organized single pane of glass. If you're on Managed, you'll have the logs ingested, and you can view requests with locks or waits.