r/Wazuh • • 15d ago

Pulling Microsoft SQL execution logs on to Wazuh Dashboard

Has anyone setup audit feature in Microsoft sql server and pushed that data into wazuh dashboard

Getting logs on sql commands execution like insert, delete, create etc.

Any kind of writeups or guides are appreciated

1 Upvotes

2 comments sorted by

1

u/External_Ad2172 15d ago

Yea, you need to run audit script on the mssql server, that will set audit and those events will start arriving at microsoft event channels

1

u/Wazuh_Marcos 15d ago

Yes, this works. The simplest way is to have SQL Server Audit write to the Windows Application log. The Wazuh agent already collects that log by default, so you only need a few custom rules on the manager to turn the events into alerts in the dashboard.

For example, the ossec.conf file includes this:

<localfile>
  <location>Application</location>
  <log_format>eventchannel</log_format>
</localfile>

You will need custom rules. Here is an example:

<group name="windows,mssql_audit,">

  <!-- Any SQL Server Audit record. Provider is MSSQLSERVER or MSSQL$<NAME> -->
  <rule id="100500" level="3">
    <if_sid>60003</if_sid>
    <field name="win.system.providerName">^MSSQL</field>
    <field name="win.system.eventID">^33205$</field>
    <options>no_full_log</options>
    <description>MSSQL audit event.</description>
  </rule>

  <rule id="100501" level="5">
    <if_sid>100500</if_sid>
    <field name="win.system.message" type="pcre2">action_id:(IN|UP|DL)\b</field>
    <options>no_full_log</options>
    <description>MSSQL audit: data modified (INSERT/UPDATE/DELETE).</description>
    <group>mssql_dml,</group>
  </rule>

</group>

This is the documentation about custom rules: https://documentation.wazuh.com/current/user-manual/ruleset/rules/custom.html. You need to restart the manager to apply the new rules, and then you can find the SQL alerts in the dashboard when the events are generated.