Tips & Troubleshooting — SQL Server Auditor

Command-Line Arguments

DBLenseSQLAuditor.exe [-s server] [-u user] [-p password] [-e]
ArgDescription
-s, --serverSQL Server name to connect to on startup
-u, --userSQL login username (implies SQL Auth)
-p, --passwordSQL login password
-eUse Windows Authentication (default)

Service Management

The DBLenseAuditCollector Windows service runs continuously in the background. Here are common management tasks:

Check Service Status

sc query DBLenseAuditCollector

Start / Stop / Restart

sc start DBLenseAuditCollector
sc stop DBLenseAuditCollector

# Or using PowerShell:
Restart-Service DBLenseAuditCollector

View Service Logs

The service writes logs to the Windows Event Log under the Application source. Use Event Viewer or PowerShell:

Get-EventLog -LogName Application -Source "DBLenseAuditCollector" -Newest 20

Update Central DB Connection

Edit appsettings.json in the service install directory (default: C:\Program Files\DBLense\AuditCollector\appsettings.json):

{
  "CentralDb": {
    "ConnectionString": "Server=YOUR_SERVER;Database=DBLenseAuditDB;Integrated Security=true;TrustServerCertificate=true;",
    "DatabaseName": "DBLenseAuditDB"
  }
}

Restart the service after changing the configuration.

Uninstall Service

sc stop DBLenseAuditCollector
sc delete DBLenseAuditCollector

Troubleshooting

IssueSolution
"Cannot create audit session"Ensure the service account has the required permissions on the target server
No events collectedCheck that the collector service is running (sc query DBLenseAuditCollector). Verify filters aren't too restrictive and workload is running.
Service won't startCheck appsettings.json for correct central DB connection string. Verify the central database is accessible from the service machine.
Dashboard can't connectVerify the central DB server name and credentials. Ensure the SQL Server is reachable from the workstation and the database exists.
"Database schema validation failed"The central database may be from an older version. Re-run the setup wizard with Central Database checked to upgrade the schema.
Event buffer emptyIncrease the buffer size or reduce the collection interval in the instance configuration
High memory usage on serviceReduce the number of tracked events or increase the collection interval per instance.
Events missing after service restartThe service uses continuous capture to prevent event loss during restarts. If events are still missing, check the collector service logs.
Multiple collectors duplicating eventsEach collector should monitor different SQL Server instances. Avoid pointing two collectors at the same target server.
Login failed for serviceIf using Windows Authentication, ensure the service account has access to both the target SQL Servers and the central database.
AI Insights not workingVerify your OpenAI API key in Settings → General. Ensure outbound HTTPS (port 443) is allowed to api.openai.com.
Webhook delivery failuresCheck the Consecutive Failures counter in Settings → Integrations. Use Test Webhook to verify connectivity. Endpoints are auto-disabled after 5 failures.
Ledger verification failedTamper detected — historical audit data has been modified outside the application. Investigate database access logs and restore from backup if needed.
"Cannot enable ledger"Ledger tables require SQL Server 2022+ or Azure SQL Database. Check your SQL Server version with SELECT @@VERSION.
Users page not visibleOnly Admin-role users can see the Users page in Settings. Log in with an Admin account.

System Requirements

Central Database

RequirementDetails
SQL ServerSQL Server 2016+ or Azure SQL Managed Instance
Ledger TablesSQL Server 2022+ or Azure SQL Database (optional, for tamper-proof audit)
Permissions (setup)Permissions to create a database on the target server, or owner-level access on an existing database
Disk SpaceDepends on audit volume. Plan for ~1 GB per million events as a baseline.

Collector Service

RequirementDetails
OSWindows 10/11 or Windows Server 2016+
Runtime.NET 8.0 (included in self-contained package)
Permissions (target servers)Permissions to create audit sessions and view server state
Permissions (central DB)Read and write access to the central audit database
NetworkTCP access to all target SQL Server instances and the central database
Memory~50–200 MB depending on number of monitored instances

UI Dashboard

RequirementDetails
OSWindows 10/11
Runtime.NET 8.0 (included in self-contained package)
Permissions (central DB)Read and write access to the central audit database
NetworkTCP access to the central database SQL Server
Display1280×720 minimum resolution
AI Insights (optional)OpenAI API key + outbound HTTPS to api.openai.com

Database Schema

The central database contains the following tables (created automatically by the setup wizard):

TablePurpose
AuditUsersDashboard user accounts with roles (Admin, Operator, Viewer) and securely hashed passwords
AuditRegisteredInstancesSQL Server instances being monitored, with per-instance event selection and filter configuration
AuditEventsAll collected audit events with timestamps, categories, statements, and performance metrics
AuditSessionsAudit session history — start/stop times, events collected per session
AuditAlertsAlert records with severity and acknowledgment tracking
AuditServiceConfigService-level configuration key-value pairs

Frequently Asked Questions

Q: What exactly happens when I delete (remove) an instance from the Dashboard tab?

Deleting a registered instance triggers a coordinated cleanup across three layers. Here is exactly what happens in each component:

1. UI Dashboard

  • A confirmation dialog appears: “Remove instance ‘SERVER_NAME’?”
  • If you click Yes, the instance is immediately removed from the grid and deselected.

2. Central Database

Only the instance registration row is deleted from dbo.AuditRegisteredInstances. This removes the connection string, all audit configuration (tracked events, filters, session settings, retention policy), and runtime status for that instance.

Important: The following data is preserved and is NOT deleted:

Central DB TableWhat Happens
AuditRegisteredInstancesRow deleted — instance configuration permanently removed
AuditEventsPreserved — all historical audit events for that server remain intact and searchable
AuditSessionsPreserved — session history records remain
AuditAlertsPreserved — all alerts referencing that server remain
AiInsightsPreserved — AI analysis results remain
AuditServiceConfigPreserved — global service configuration unchanged

This means you keep your full audit trail for compliance and forensic purposes even after removing the instance from active monitoring.

3. Collector Service

On the next collection cycle (typically within seconds), the collector service detects that the instance is no longer registered and performs the following cleanup:

  • Connects to the target SQL Server instance
  • If Persist XE Sessions was OFF (the default): the XEvent session (DBLenseAudit) is stopped and dropped (DROP EVENT SESSION) — completely removed from the monitored instance
  • If Persist XE Sessions was ON: the XEvent session is stopped but left defined on the server (can be restarted manually if needed)
  • If Dual Session mode was enabled, both sessions (primary and _B) are stopped/dropped
  • The instance is removed from the collector’s in-memory tracking — no further collection cycles run for that server

4. On the Deleted SQL Server Instance

Component on Target InstanceWhat Happens
XEvent Session (DBLenseAudit)Dropped (or stopped only if PersistXeSessions was ON)
Security DDL Trigger (dbl_tr_security_audit)Left in place — not automatically removed
Security Log Table (master.dbo.DBLenseAuditSecurityLog)Left in place — not automatically removed
SQL Server Audit (Compliance Pack)Left in place — the SERVER AUDIT continues running independently

Tip: If you want to fully clean up the target instance after deletion, manually run the following on the monitored SQL Server:

-- Remove the security DDL trigger (if installed)
IF EXISTS (SELECT 1 FROM sys.server_triggers WHERE name = 'dbl_tr_security_audit')
    DROP TRIGGER [dbl_tr_security_audit] ON ALL SERVER;

-- Remove the security log table (if installed)
IF OBJECT_ID('master.dbo.DBLenseAuditSecurityLog') IS NOT NULL
    DROP TABLE master.dbo.DBLenseAuditSecurityLog;

-- Remove the Server Audit (if Compliance Pack was enabled)
-- See scripts/install-server-audit-onprem.sql UNINSTALL section

Q: Can I re-register an instance after deleting it?

Yes. Click Register Instance on the Dashboard tab and enter the same server connection details. A new registration is created with default configuration. The collector service will create a fresh XEvent session on the next cycle. Previously collected audit events for that server are still in the central database and will appear in search results alongside new events.


Q: How do I permanently delete historical audit events for a removed instance?

Historical events are retained by design for compliance. If you need to remove them (e.g., decommissioned server), run the following against the central database:

-- Delete all events for a specific server (use with caution)
DELETE FROM dbo.AuditEvents WHERE ServerName = 'YOUR_SERVER_NAME';

Warning: This operation is irreversible. If Ledger Tables are enabled, DELETE is blocked on the append-only AuditEventsLedger table by design — this is the tamper-proof guarantee.