@cryptotaxi247 / netdata-1 / commits / 2d94de981

fix(go.d/mssql): fix database size overflow and Windows Auth docs (#22129)

Costa Tsaousis committed Apr 3, 2026 at 11:32 UTC 2d94de981576aba93b7967dd908e928b9b8131ce
3 files changed +25 -20
src/go/plugin/go.d/collector/mssql/metadata.yaml
+23 -18
@@ -129,12 +129,26 @@ modules:
129 Netdata service account access to SQL Server.
130
131 By default, the Netdata service runs as `Local System`. The identity it presents to
132 - SQL Server depends on your environment:
132 + SQL Server depends on whether the connection is local or remote:
133
134 - **Domain-joined machine (Active Directory):**
134 + **Local connection (Netdata and SQL Server on the same machine):**
135
136 - `Local System` authenticates as the computer account (`DOMAIN\COMPUTERNAME$`).
137 - Replace `DOMAIN\COMPUTERNAME$` with your actual values
136 + `Local System` always authenticates as `NT AUTHORITY\SYSTEM`, regardless of whether
137 + the machine is domain-joined or in a workgroup.
138 +
139 + ```sql
140 + CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS;
141 + GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM];
142 + GRANT VIEW ANY DEFINITION TO [NT AUTHORITY\SYSTEM];
143 + USE msdb;
144 + CREATE USER [NT AUTHORITY\SYSTEM] FOR LOGIN [NT AUTHORITY\SYSTEM];
145 + GRANT SELECT ON dbo.sysjobs TO [NT AUTHORITY\SYSTEM];
146 + ```
147 +
148 + **Remote connection (Netdata connects to SQL Server on another machine):**
149 +
150 + On a domain-joined machine, `Local System` authenticates over the network as the
151 + computer account (`DOMAIN\COMPUTERNAME$`). Replace with your actual values
152 (e.g., `MYDOM\SQLBOX01$`).
153
154 ```sql
@@ -146,19 +160,10 @@ modules:
160 GRANT SELECT ON dbo.sysjobs TO [DOMAIN\COMPUTERNAME$];
161 ```
162
149 - **Workgroup machine (no Active Directory, localhost only):**
150 -
151 - `Local System` authenticates as `NT AUTHORITY\SYSTEM`.
152 - This only works when SQL Server runs on the same machine.
153 -
154 - ```sql
155 - CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS;
156 - GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM];
157 - GRANT VIEW ANY DEFINITION TO [NT AUTHORITY\SYSTEM];
158 - USE msdb;
159 - CREATE USER [NT AUTHORITY\SYSTEM] FOR LOGIN [NT AUTHORITY\SYSTEM];
160 - GRANT SELECT ON dbo.sysjobs TO [NT AUTHORITY\SYSTEM];
161 - ```
163 + For the default `Local System` service account, remote Windows Authentication works
164 + only on domain-joined machines, where it can authenticate as the computer account.
165 + In workgroups, use a different Windows service account if you need remote Windows
166 + Authentication.
167
168 > **Note**: To verify which account SQL Server sees, connect with Windows Authentication
169 > and run `SELECT SYSTEM_USER`.
@@ -306,7 +311,7 @@ modules:
311
312 When no username/password is provided in the DSN, the driver uses the Netdata service account's
313 Windows credentials. By default, the Netdata service runs as `Local System`, which authenticates
309 - to SQL Server as the computer account (`DOMAIN\COMPUTERNAME$`).
314 + to a local SQL Server as `NT AUTHORITY\SYSTEM`.
315
316 See the [Grant Windows Authentication access](#grant-windows-authentication-access-optional) prerequisite
317 to configure SQL Server for this.
src/go/plugin/go.d/collector/mssql/queries.go
+1 -1
@@ -122,7 +122,7 @@ WHERE object_name LIKE '%Locks%'
122 const queryDatabaseSize = `
123 SELECT
124 DB_NAME(database_id) AS database_name,
125 - SUM(size) * 8 * 1024 AS size_bytes
125 + SUM(CAST(size AS BIGINT)) * 8 * 1024 AS size_bytes
126 FROM sys.master_files
127 WHERE type = 0 -- data files only
128 AND database_id > 4 -- exclude system databases
src/go/plugin/go.d/config/go.d/mssql.conf
+1 -1
@@ -9,7 +9,7 @@
9 # dsn: "sqlserver://netdata_user:password@localhost/INSTANCENAME"
10 #
11 # - name: windows_auth
12 -# dsn: "sqlserver://localhost:1433?trusted_connection=yes"
12 +# dsn: "sqlserver://localhost:1433"
13 #
14 # - name: full_example
15 # dsn: "sqlserver://netdata_user:password@localhost:1433"