Get comprehensive insights into your Azure SQL Managed Instance performance with database monitoring, query analysis, and system health metrics using the New Relic Distribution of OpenTelemetry (NRDOT) collector.
Guided installation
To install this through the New Relic UI instead, go to one.newrelic.com > Integrations & Agents > Microsoft SQL Server (Database 360) . Follow the on-screen instructions to set up the integration. This page covers manual installation only.
ヒント
To run the collector on Windows, refer to Azure SQL Managed Instance on Windows. For Azure SQL Database, refer to Linux or Windows.
Prerequisites
- A New Relic account with a valid license key.
- Network connectivity to the New Relic OTLP endpoint for your region.
- Azure SQL Managed Instance requirements:
- An Azure SQL Managed Instance.
- The managed instance admin login and password (or another login with the
sysadminserver role). - Network access from the collector host to the managed instance on port
1433(private endpoint) or3342(public endpoint). The network security group (NSG) on the managed instance subnet must allow the connection.
- Linux system requirements:
- The
sqlcmdutility installed on your Linux system.
- The
Install NRDOT Collector
Download and install the NRDOT package for your Linux distribution. Replace <NRDOT_VERSION> with the latest release tag from the nrdot-collector-releases page.
重要
Install the NRDOT Collector on a VM in the same virtual network as your managed instance (or a peered network) for the best connectivity. A managed instance is private by default, so a machine outside the virtual network can't reach it unless you enable the public endpoint.
Create monitoring user
Run this script as the managed instance admin to create the newrelic monitoring user and grant the necessary permissions for collecting SQL Server metrics.
Create a file named
nr-grant-permission-mi.sql.Paste the following SQL script to create the
newrelicmonitoring user and replace<YOUR_PASSWORD>with your desired password:USE [master];GOCREATE LOGIN [newrelic] WITH PASSWORD = '<YOUR_PASSWORD>';GO-- Instance-level permissionsGRANT VIEW SERVER STATE TO [newrelic];GRANT VIEW ANY DEFINITION TO [newrelic];GRANT VIEW ANY DATABASE TO [newrelic];GO-- Grant read access privileges to all user databasesDECLARE @name SYSNAME;DECLARE db_cursor CURSOR READ_ONLY FORWARD_ONLY FORSELECT [name]FROM [master].[sys].[databases]WHERE [name] NOT IN ('master', 'msdb', 'tempdb', 'model', 'distribution')AND [state] = 0; -- Only online databasesOPEN db_cursor;FETCH NEXT FROM db_cursor INTO @name;WHILE @@FETCH_STATUS = 0BEGINBEGIN TRYEXEC('USE [' + @name + '];IF NOT EXISTS (SELECT 1 FROM sys.database_principals WHERE name = ''newrelic'')BEGINCREATE USER [newrelic] FOR LOGIN [newrelic];END;GRANT VIEW DATABASE STATE TO [newrelic];');END TRYBEGIN CATCHPRINT 'Error on ' + @name + ': ' + ERROR_MESSAGE();END CATCHFETCH NEXT FROM db_cursor INTO @name;ENDCLOSE db_cursor;DEALLOCATE db_cursor;GOExecute the script using
sqlcmdwith any login that has permission to create logins and grant server-level permissions (for example, the managed instance admin login, or another account with thesysadminrole). Replace<YOUR-MI-HOST>with your managed instance host name (for example,myinstance.abc123.database.windows.net, ormyinstance.public.abc123.database.windows.net,3342for the public endpoint) and<YOUR_ADMIN_PASSWORD>with the admin password:bash$sqlcmd -S <YOUR-MI-HOST> -U <YOUR_ADMIN_USER> -P '<YOUR_ADMIN_PASSWORD>' -C -i nr-grant-permission-mi.sql(Optional) Verify the user is created successfully with the correct permissions:
bash$sqlcmd -S <YOUR-MI-HOST> -U <YOUR_ADMIN_USER> -P '<YOUR_ADMIN_PASSWORD>' -C -Q "SELECT sp.name AS [User], p.permission_name AS [Permission_Granted] FROM sys.server_permissions p JOIN sys.server_principals sp ON p.grantee_principal_id = sp.principal_id WHERE sp.name = 'newrelic';"ヒント
- Use your managed instance admin login to execute these commands. The script skips the system databases (
master,msdb,tempdb,model) and any database that isn't online. - To securely manage sensitive information, such as database credentials, store them in secret management tools.
- Use your managed instance admin login to execute these commands. The script skips the system databases (
Configure NRDOT Collector
Choose your configuration option based on your monitoring requirements:
Create a configuration file named
mssql-config.yaml:bash$sudo nano /etc/nrdot-collector/mssql-config.yamlAdd the following configuration to the
mssql-config.yamlfile created in the previous step:full configuration
This configuration focuses on essential database monitoring for your Azure SQL Managed Instance environment. To enable comprehensive monitoring with all available metrics, refer to the configuration reference.
1receivers:2 nrsqlserver:3 collection_interval: 15s4 # Connection details - Use your Managed Instance host name5 username: newrelic6 password: YOUR_PASSWORD7 server: myinstance.xxxxxxxxxxxx.database.windows.net8 port: 14339
10 # Enable comprehensive database metrics11 metrics:12 sqlserver.database.count:13 enabled: true14 sqlserver.database.io:15 enabled: true16 sqlserver.database.latency:17 enabled: true18 sqlserver.database.operations:19 enabled: true20 sqlserver.database.tempdb.space:21 enabled: true22 sqlserver.database.tempdb.version_store.size:23 enabled: true24 sqlserver.deadlock.rate:25 enabled: true26 sqlserver.os.wait.duration:27 enabled: true28 sqlserver.processes.blocked:29 enabled: true30 sqlserver.memory.grants.pending.count:31 enabled: true32 sqlserver.database.file.size:33 enabled: true34 sqlserver.memory.area:35 enabled: true36
37 # Enable query sample, top query, query plan, and top procedure log collection38 events:39 db.server.query_sample:40 enabled: true41 db.server.top_query:42 enabled: true43 db.server.query_plan:44 enabled: true45 db.server.top_procedure:46 enabled: true47
48 # Top query collection configuration49 top_query_collection:50 lookback_time: 60s51 max_query_sample_count: 100052 top_query_count: 25053 collection_interval: 60s54 collect_full_query_text: true55 allowed_comment_keys:56 - nr_service_guid57
58 # Query sample collection configuration59 query_sample_collection:60 max_rows_per_query: 10061 collect_full_query_text: true62 allowed_comment_keys:63 - nr_service_guid64
65 # Top stored procedure collection configuration66 top_procedure_collection:67 max_procedure_sample_count: 100068 top_procedure_count: 25069 collection_interval: 60s70
71 resource_attributes:72 db.system.version:73 enabled: true74 sqlserver.db.edition:75 enabled: true76
77processors:78 memory_limiter:79 check_interval: ${env:NR_MEM_LIMITER_CHECK_INTERVAL:-1s}80 limit_mib: ${env:NR_MEM_LIMITER_LIMIT_MIB:-200}81 spike_limit_mib: ${env:NR_MEM_LIMITER_SPIKE_MIB:-50}82
83exporters:84 otlp:85 endpoint: https://otlp.nr-data.net:431886 headers:87 api-key: YOUR_LICENSE_KEY88 tls:89 insecure: false90 compression: gzip91
92 sending_queue:93 enabled: true94 sizer: bytes95 queue_size: 100_000_00096 num_consumers: 1097 batch:98 sizer: bytes99 max_size: 1_000_000100 min_size: 0101 flush_timeout: 5s102
103service:104 telemetry:105 metrics:106 level: none107
108 pipelines:109 metrics:110 receivers: [nrsqlserver]111 processors: [memory_limiter]112 exporters: [otlp]113
114 logs:115 receivers: [nrsqlserver]116 processors: [memory_limiter]117 exporters: [otlp]ヒント
The
logspipeline doesn't carry collector debug or internal agent logs. It transmits SQL Server query telemetry, including query text, execution plans, and sample data. Thenrsqlserverreceiver captures this telemetry throughdb.server.query_sample,db.server.top_query,db.server.query_plan, anddb.server.top_procedureevents emitted as OpenTelemetry log records.The
db.server.top_procedureevent requires SQL Server 2017 CU3 or later, which introduced support forsys.dm_exec_procedure_stats.total_spills. On earlier versions, this event doesn't emit data and logs an error. Other events remain unaffected. Accessingsys.dm_exec_procedure_statsrequiresVIEW SERVER STATE(orVIEW SERVER PERFORMANCE STATE, depending on the SQL Server version). Additionally,VIEW ANY DEFINITIONis required forOBJECT_NAMEandOBJECT_SCHEMA_NAMEto resolve correctly across all user databases, andCONNECT SQLis needed to set up initial sessions. The monitoring user created in Create monitoring user includes all 3 permissions.
Update NRDOT Collector configuration
After configuring your YAML file with the interactive inputs above, complete the NRDOT Collector setup:
Edit the service configuration file using the following command:
bash$sudo nano /etc/nrdot-collector/nrdot-collector.confUpdate the configuration path to point to your new
mssql-config.yamlfile:bash$OTELCOL_CONFIG="/etc/nrdot-collector/mssql-config.yaml"(Optional) Validate the NRDOT Collector configuration:
bash$sudo /usr/bin/nrdot-collector validate --config=/etc/nrdot-collector/mssql-config.yamlヒント
To correlate your application performance with database operations, you can set up database service identification. For more information, refer to database service identification setup guide.
Restart NRDOT Collector
After updating your configuration, restart the NRDOT Collector service:
$sudo systemctl restart nrdot-collectorヒント
Always restart the NRDOT Collector service after making configuration changes to ensure the new settings take effect.
Find and use your data
Once your data is being collected, you can access comprehensive SQL Server database monitoring through the New Relic UI.
To find your SQL Server database entity in New Relic:
Go to one.newrelic.com > All capabilities > Databases.
From the Entity type dropdown, select MSSQL instance, then click Apply.
Select your SQL Server database from the list of entities.
After setting up SQL Server monitoring with NRDOT, you can:
- Create custom dashboards to visualize your database metrics
- Set up alerts for critical database performance thresholds
- Explore your data using New Relic query capabilities
Related documentation
Set up APM-database correlation
Learn how to correlate your application performance with database operations in New Relic.
Troubleshooting
Learn how to troubleshoot your MSSQL Azure SQL Managed Instance monitoring setup in New Relic.
Metrics reference
Learn about the available metrics collected by the NRDOT Collector.