I hope this message finds you well.
I am currently working on configuring Wazuh to monitor Microsoft SQL Server audit logs, and I need some assistance regarding how to capture specific SQL activities such as:
Here is the configuration I have on the Wazuh agent side for collecting relevant logs:
<localfile>
<location>Application</location>
<log_format>eventlog</log_format>
</localfile>
<localfile>
<location>C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG</location>
<log_format>mssql_log</log_format>
<ignore_binaries>yes</ignore_binaries>
</localfile>
<localfile>
<location>C:\Windows\System32\winevt\Logs\Application.evtx</location>
<log_format>eventlog</log_format>
</localfile>
<localfile>
<log_format>json</log_format>
<location>Security</location>
</localfile>
Questions:
How can I enable SQL Server auditing to track the activities mentioned above and send these logs to Wazuh for analysis?
Which decoders are required in Wazuh to properly parse SQL Server audit logs that capture actions such as database creation, deletion, table operations, and record modifications?
What custom rule configurations in Wazuh would be needed to detect and alert on these SQL activities (e.g., creating or dropping databases, creating or deleting tables, modifying records)?
Additionally, I would appreciate if you could clarify how to enable auditing for application logs to ensure that the SQL Server activities are properly captured.
Thank you in advance for your support and guidance. I look forward to your advice
Thanks,
Susikanth


I have checked the logs to the ERRORLOG file located at:
1) C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG
Here are some sample logs from the file:
2024-12-10 18:07:20.51 Logon Login succeeded for user 'NT SERVICE\SQLTELEMETRY'. Connection made using Integrated authentication. [CLIENT: <local machine>]
2024-12-10 18:10:24.71 Logon Login succeeded for user 'NT Service\SQLIaaSExtensionQuery'. Connection made using Integrated authentication. [CLIENT: <local machine>]
2024-12-10 18:11:00.53 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:12:42.07 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:12:43.03 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:14:44.47 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:16:16.36 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:16:16.42 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:17:20.81 Logon Login succeeded for user 'NT SERVICE\SQLTELEMETRY'. Connection made using Integrated authentication. [CLIENT: <local machine>]
2024-12-10 18:18:20.52 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:20:50.13 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:23:46.39 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:25:40.53 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:27:20.92 Logon Login succeeded for user 'NT SERVICE\SQLTELEMETRY'. Connection made using Integrated authentication. [CLIENT: <local machine>]
2024-12-10 18:28:39.38 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:30:16.09 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:30:55.35 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:31:50.25 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:32:38.94 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:33:00.54 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:33:56.13 Logon Login succeeded for user 'demo'. Connection made using SQL Server authentication. [CLIENT: 10.6.4.222]
2024-12-10 18:37:21.04 Logon Login succeeded for user 'NT SERVICE\SQLTELEMETRY'. Connection made using Integrated authentication. [CLIENT: <local machine>]
2) As mentioned, I added the following global configuration in the ossec.conf file to enable archive logging:
<global>
<jsonout_output>yes</jsonout_output>
<alerts_log>yes</alerts_log>
<logall>yes</logall>
<logall_json>yes</logall_json>
<email_notification>no</email_notification>
<smtp_server>smtp.example.wazuh.com</smtp_server>
<email_from>wa...@example.wazuh.com</email_from>
<email_to>reci...@example.wazuh.com</email_to>
<email_maxperhour>12</email_maxperhour>
<email_log_source>alerts.log</email_log_source>
<agents_disconnection_time>10m</agents_disconnection_time>
<agents_disconnection_alert_time>0</agents_disconnection_alert_time>
<update_check>yes</update_check>
</global>
After applying these changes, I also restarted the wazuh-manager service .However, even after the restart, the logs are not being received in the archive logs. Here are the sample logs from the agent’s ossec.log located at:
3) C:\Program Files (x86)\ossec-agent\ossec.log
2024/12/10 18:47:55 rootcheck: INFO: Started (pid: 4896).
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\batfile', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\cmdfile', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (4102): Connected to the server ([192.168.128.103]:1514/tcp).
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\comfile', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\exefile', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\piffile', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\AllFilesystemObjects', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\Directory', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 sca: INFO: Module started.
2024/12/10 18:47:55 sca: INFO: Loaded policy 'C:\Program Files (x86)\ossec-agent\ruleset\sca\cis_win2019.yml'
2024/12/10 18:47:55 sca: INFO: Starting Security Configuration Assessment scan.
2024/12/10 18:47:55 sca: INFO: Starting evaluation of policy: 'C:\Program Files (x86)\ossec-agent\ruleset\sca\cis_win2019.yml'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\Folder', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-modulesd:ciscat: INFO: Module disabled. Exiting...
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\Protocols [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-modulesd:osquery: INFO: Module disabled. Exiting...
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Classes\Protocols', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-modulesd:agent-upgrade: INFO: (8153): Module Agent Upgrade started.
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Policies [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Policies', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Security', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-modulesd:syscollector: INFO: Module started.
2024/12/10 18:47:55 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\KnownDLLs', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurePipeServers\winreg', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\URL [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\URL', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Windows [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Windows', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components [x64]', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6002): Monitoring registry entry: 'HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components', with options 'size | permissions | owner | group | mtime | hash_md5 | hash_sha1 | hash_sha256'
2024/12/10 18:47:55 wazuh-agent: INFO: (6003): Monitoring path: 'c:\programdata\microsoft\windows\start menu\programs\startup', with options 'size | permissions | owner | group | mtime | inode | hash_md5 | hash_sha1 | hash_sha256 | attributes | realtime'.
2024/12/10 18:47:55 wazuh-agent: INFO: (6003): Monitoring path: 'c:\windows', with options 'size | permissions | owner | group | mtime | inode | hash_md5 | hash_sha1 | hash_sha256 | attributes | scheduled'.
2024/12/10 18:47:55 wazuh-agent: INFO: (6003): Monitoring path: 'c:\windows\system32', with options 'size | permissions | owner | group | mtime | inode | hash_md5 | hash_sha1 | hash_sha256 | attributes | scheduled'.
2024/12/10 18:47:55 wazuh-agent: INFO: (6003): Monitoring path: 'c:\windows\system32\drivers\etc', with options 'size | permissions | owner | group | mtime | inode | hash_md5 | hash_sha1 | hash_sha256 | attributes | scheduled'.
2024/12/10 18:47:55 wazuh-agent: INFO: (6003): Monitoring path: 'c:\windows\system32\wbem', with options 'size | permissions | owner | group | mtime | inode | hash_md5 | hash_sha1 | hash_sha256 | attributes | scheduled'.
2024/12/10 18:47:55 wazuh-agent: INFO: (6003): Monitoring path: 'c:\windows\system32\windowspowershell\v1.0', with options 'size | permissions | owner | group | mtime | inode | hash_md5 | hash_sha1 | hash_sha256 | attributes | scheduled'.
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'file' entry 'c:\programdata\microsoft\windows\start menu\programs\startup\desktop.ini'
2024/12/10 18:47:55 wazuh-agent: INFO: (6207): Ignore 'file' sregex '.log$|.htm$|.jpg$|.png$|.chm$|.pnf$|.evtx$'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\Security\Policy\Secrets'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\Security\SAM\Domains\Account\Users'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MpsSvc\Parameters\AppCs'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MpsSvc\Parameters\PortKeywords\DHCP'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MpsSvc\Parameters\PortKeywords\IPTLSIn'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MpsSvc\Parameters\PortKeywords\IPTLSOut'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MpsSvc\Parameters\PortKeywords\RPC-EPMap'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MpsSvc\Parameters\PortKeywords\Teredo'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\PolicyAgent\Parameters\Cache'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx'
2024/12/10 18:47:55 wazuh-agent: INFO: (6206): Ignore 'registry' entry 'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\ADOVMPPackage\Final'
2024/12/10 18:47:55 wazuh-agent: INFO: (6207): Ignore 'registry' sregex '\Enum$'
2024/12/10 18:47:55 wazuh-agent: INFO: Started (pid: 4896).
2024/12/10 18:47:55 rootcheck: INFO: Starting rootcheck scan.
2024/12/10 18:47:55 wazuh-agent: INFO: (6000): Starting daemon...
2024/12/10 18:47:55 wazuh-agent: INFO: (6010): File integrity monitoring scan frequency: 43200 seconds
2024/12/10 18:47:55 wazuh-agent: INFO: (6008): File integrity monitoring scan started.
2024/12/10 18:47:55 wazuh-agent: INFO: Windows version is 6.0 or newer. (Microsoft Windows Server 2019 Datacenter [Ver: 10.0.17763.5696] - Wazuh v4.7.5).
2024/12/10 18:47:55 wazuh-agent: INFO: (1951): Analyzing event log: 'Application'.
2024/12/10 18:47:55 wazuh-agent: INFO: (1950): Analyzing file: 'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG'.
2024/12/10 18:47:55 wazuh-agent: INFO: (1951): Analyzing event log: 'C:\Windows\System32\winevt\Logs\Application.evtx'.
2024/12/10 18:47:56 wazuh-agent: WARNING: (1958): Log file 'Security' is duplicated.
2024/12/10 18:47:56 wazuh-agent: INFO: (1951): Analyzing event log: 'Security'.
2024/12/10 18:47:56 wazuh-agent: INFO: (1951): Analyzing event log: 'System'.
2024/12/10 18:47:56 wazuh-agent: INFO: (1950): Analyzing file: 'active-response\active-responses.log'.
2024/12/10 18:47:56 wazuh-agent: INFO: Started (pid: 4896).
2024/12/10 18:47:58 sca: INFO: Evaluation finished for policy 'C:\Program Files (x86)\ossec-agent\ruleset\sca\cis_win2019.yml'
2024/12/10 18:47:58 sca: INFO: Security Configuration Assessment scan finished. Duration: 3 seconds.
2024/12/10 18:48:00 rootcheck: INFO: Ending rootcheck scan.
2024/12/10 18:48:06 wazuh-agent: INFO: (6009): File integrity monitoring scan ended.
2024/12/10 18:48:06 wazuh-agent: INFO: FIM sync module started.
2024/12/10 18:48:06 wazuh-agent: INFO: (6012): Real-time file integrity monitoring started.
I look forward to your advice
Thanks,
Susikanth

I hope you're doing well.
I have removed the duplicate security configurations, and as a result, there are no longer any duplicate error messages in the ossec.logs.
I have a query regarding the capture of specific SQL security events on the Wazuh dashboard. Specifically, I would like to capture the following SQL activities:
We are currently capturing SQL login and failed activity, and we would like to capture the above SQL events in a similar manner.
Could you kindly guide me on how to configure any decoder or rule for SQL Activity?
Thank you for your assistance.
Thanks,
Susikanth