Set up Microsoft SQL Server monitoring using the NRDOT Collector on Windows environments to monitor AWS RDS for SQL Server instances, using a group Managed Service Account (gMSA). To monitor in a self-hosted environment, refer to Windows self-hosted instrumentation.
To install this through the New Relic UI instead, go to one.newrelic.com > Integrations & Agents > MSSQL (OpenTelemetry) . Follow the on-screen instructions to set up the integration. This page covers manual installation only.
This page covers gMSA authentication. If your environment uses a different authentication method, see SQL Server Authentication or Windows Domain Authentication.
Prerequisites
Before monitoring your Microsoft SQL Server with NRDOT using gMSA authentication, make sure you've:
- A New Relic account with a valid license key.
- Network connectivity to the New Relic OTLP endpoint for your region.
- SQL Server requirements:
- SQL Server 2017 or later on Amazon RDS.
- RDS master user credentials or credentials for a SQL Server login with the
rds_superuserrole. - RDS Security Group configured to allow connections on port
1433or a custom port. - SQL Server Management Studio (SSMS) or the
sqlcmdutility. - RDS instance associated with the AWS Active Directory service.
- Your RDS SQL Server endpoint URL, which can be found in your AWS RDS Console under Connectivity & security. For more information, refer to AWS RDS documentation.
- An Active Directory environment with gMSA support.
- A domain-joined Windows EC2 instance authorized to use the gMSA account.
Install NRDOT Collector
Download and install the NRDOT Collector using PowerShell:
$[Net.ServicePointManager]::SecurityProtocol = 'tls12, tls'; $NRDOT_VERSION = (Invoke-RestMethod -Uri "https://api.github.com/repos/newrelic/nrdot-collector-releases/releases/latest").tag_name; $WebClient = New-Object System.Net.WebClient; $WebClient.Headers.Add("User-Agent", "Mozilla/5.0"); $WebClient.DownloadFile("https://github.com/newrelic/nrdot-collector-releases/releases/download/$NRDOT_VERSION/nrdot-collector_${NRDOT_VERSION}_windows_x64.msi", "$env:TEMP\nrdot-collector.msi"); Start-Process msiexec.exe -ArgumentList "/i `"$env:TEMP\nrdot-collector.msi`" /qn /norestart /L*V `"$env:TEMP\nrdot_install.log`"" -Wait; Get-Service nrdot-collector -ErrorAction SilentlyContinueCreate monitoring user
Connect to your RDS SQL Server instance using SQL Server Management Studio (SSMS) or sqlcmd with administrative privileges.
In your SQL Server Management Studio (SSMS), run the following script to create a login for your gMSA account and grant the necessary permissions. Replace all occurrences of <YOUR_DOMAIN>\<YOUR_GMSA_USERNAME> with your actual domain and account name.
USE [master];GO
CREATE LOGIN [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$] FROM WINDOWS;GO
GRANT VIEW ANY DATABASE TO [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$];GRANT VIEW SERVER STATE TO [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$];GRANT VIEW ANY DEFINITION TO [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$];GO-- Grant access to all databases DECLARE @name SYSNAME;DECLARE db_cursor CURSOR READ_ONLY FORWARD_ONLY FOR SELECT [name] FROM [master].[sys].[databases] WHERE [name] NOT IN ('master','msdb','model','rdsadmin','distribution') AND [state] = 0;OPEN db_cursor;FETCH NEXT FROM db_cursor INTO @name;WHILE @@FETCH_STATUS = 0BEGIN BEGIN TRY EXEC('USE [' + @name + ']; IF NOT EXISTS (SELECT 1 FROM sys.database_principals WHERE name = ''<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$'') BEGIN CREATE USER [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$] FOR LOGIN [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$]; END; GRANT VIEW DATABASE STATE TO [<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$];'); END TRY BEGIN CATCH PRINT 'Error on ' + @name + ': ' + ERROR_MESSAGE(); END CATCH FETCH NEXT FROM db_cursor INTO @name;ENDCLOSE db_cursor;DEALLOCATE db_cursor;GOヒント
To securely manage sensitive information, such as database credentials, store them in secret management tools.
Run as gMSA account
Configure the NRDOT Collector service to run as your gMSA account using PowerShell. Replace <YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$ with your domain and gMSA account name. You must include the $ at the end, as it is required for gMSA accounts:
$# Stop the NRDOT Collector service$Stop-Service nrdot-collector$
$# Configure service to use gMSA account$# Use cmd /c to avoid PowerShell treating $ as a variable$cmd /c 'sc config nrdot-collector obj= "<YOUR_DOMAIN>\<YOUR_GMSA_USERNAME>$" password= ""'$
$# Verify the configuration$Get-WmiObject Win32_Service -Filter "Name='nrdot-collector'" | Select Name, StartName$
$# Start the NRDOT Collector service $Start-Service nrdot-collector重要
The gMSA accounts don't require passwords. Keep it empty when configuring the service.
Configure NRDOT Collector
Create a configuration file named
mssql-config.yamlin PowerShell as an Administrator:bash$New-Item -Path "C:\Program Files\nrdot-collector\mssql-config.yaml" -ItemType FileAdd the following configuration to the
mssql-config.yamlfile created in the previous step:
full configuration
This configuration focuses on essential database monitoring for your RDS environment. To enable comprehensive monitoring with all available metrics, refer to the configuration reference.
1receivers:2 nrsqlserver:3 collection_interval: 15s4 datasource: "server=mydb-instance.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com;port=1433;integrated security=true;encrypt=true;TrustServerCertificate=true;"5
6 # Enable comprehensive database metrics7 metrics:8 sqlserver.database.count:9 enabled: true10 sqlserver.database.io:11 enabled: true12 sqlserver.database.latency:13 enabled: true14 sqlserver.database.operations:15 enabled: true16 sqlserver.database.tempdb.space:17 enabled: true18 sqlserver.database.tempdb.version_store.size:19 enabled: true20 sqlserver.deadlock.rate:21 enabled: true22 sqlserver.os.wait.duration:23 enabled: true24 sqlserver.processes.blocked:25 enabled: true26 sqlserver.memory.grants.pending.count:27 enabled: true28 sqlserver.database.file.size:29 enabled: true30 sqlserver.memory.area:31 enabled: true32
33 # Enable query sample, top query, query plan, and top procedure log collection34 events:35 db.server.query_sample:36 enabled: true37 db.server.top_query:38 enabled: true39 db.server.query_plan:40 enabled: true41 db.server.top_procedure:42 enabled: true43
44 # Top query collection configuration45 top_query_collection:46 lookback_time: 60s47 max_query_sample_count: 100048 top_query_count: 25049 collection_interval: 60s50 collect_full_query_text: true51 allowed_comment_keys:52 - nr_service_guid53
54 # Query sample collection configuration55 query_sample_collection:56 max_rows_per_query: 10057 collect_full_query_text: true58 allowed_comment_keys:59 - nr_service_guid60
61 # Top stored procedure collection configuration62 top_procedure_collection:63 max_procedure_sample_count: 100064 top_procedure_count: 25065 collection_interval: 60s66
67 resource_attributes:68 db.system.version:69 enabled: true70 sqlserver.db.edition:71 enabled: true72
73processors:74 memory_limiter:75 check_interval: ${env:NR_MEM_LIMITER_CHECK_INTERVAL:-1s}76 limit_mib: ${env:NR_MEM_LIMITER_LIMIT_MIB:-200}77 spike_limit_mib: ${env:NR_MEM_LIMITER_SPIKE_MIB:-50}78
79exporters:80 otlp:81 endpoint: https://otlp.nr-data.net:431882 headers:83 api-key: YOUR_LICENSE_KEY84 tls:85 insecure: false86 compression: gzip87
88 sending_queue:89 enabled: true90 sizer: bytes91 queue_size: 100_000_00092 num_consumers: 1093 batch:94 sizer: bytes95 max_size: 1_000_00096 min_size: 097 flush_timeout: 5s98
99service:100 telemetry:101 metrics:102 level: none103
104 pipelines:105 metrics:106 receivers: [nrsqlserver]107 processors: [memory_limiter]108 exporters: [otlp]109
110 logs:111 receivers: [nrsqlserver]112 processors: [memory_limiter]113 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 gMSA login created in Create monitoring user already has all 3 permissions.
Update Windows Service Registry
Update the Windows Service Registry to use the new
mssql-config.yamlfile using one of the following methods:For PowerShell: Run the following command as Administrator:
bash$Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\nrdot-collector" -Name "ImagePath" -Value '"C:\Program Files\nrdot-collector\nrdot-collector.exe" --config "C:\Program Files\nrdot-collector\mssql-config.yaml"'For Command Prompt: If PowerShell isn't available, use Command Prompt instead and run the following command as Administrator:
bash$sc config "nrdot-collector" binPath= "\"C:\Program Files\nrdot-collector\nrdot-collector.exe\" --config \"C:\Program Files\nrdot-collector\mssql-config.yaml\""
Validate the NRDOT Collector configuration to ensure it's correctly formatted and will work properly:
bash$& "C:\Program Files\nrdot-collector\nrdot-collector.exe" validate --config="C:\Program Files\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 set up database service identification.
Restart NRDOT Collector
After updating your configuration, restart the NRDOT Collector service on your domain-joined EC2 Windows instance:
$net stop nrdot-collector$net start nrdot-collectorVerify that the service is running under the gMSA account by checking Windows Services (services.msc). The Log On As column should show your gMSA account, for example, CORP\SQL-gMSA$.
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 https://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