First, we apply this configuration in the /var/ossec/etc/ossec.conf to monitor the MySQL log:
```
<localfile>
<log_format>syslog</log_format>
<location>/var/log/mysql/mysql_general.log</location>
</localfile>
```
Restart the wazuh-agent or wazuh-manager (depending on where you are configuring) to apply the configuration:
systemctl restart wazuh-agent
Note: Please note, that in this case we are, going to use syslog as log format.
Now, let’s add the following custom decoder that will allow us to decode the mysql log format you have shared. Add the following decoder in /var/ossec/etc/decoders/local_decoder.xml of wazuh-manager.
```
<decoder name="custom_mysql">
<prematch>\d+\s\w+\s+</prematch>
<regex>\s+(\d+)\s(\w+)\s+(\w\.*)</regex>
<order>code, _action, command</order>
</decoder>
```
Note: The name action is reserved, therefore \_action has been used.
Next, we are going to create a rule that allows us to generate an alert for the cases in which the log corresponds to a query (when the field decoded as \_action corresponds to the Query value. For that, we add the following alert in the file /var/ossec/etc/rules/local_rules.xml.
```
<group name="mysql,">
<rule id="100150" level="3">
<decoded_as>custom_mysql</decoded_as>
<field name="_action">Query</field>
<description>The following query '$(command)' was run</description>
</rule>
</group>
```
Now, we restart the wazuh-manager to apply the changes in the decoders and rules:
```
systemctl restart wazuh-manager
```