# Can audit plugin include the execute\_sql command, but exclude selects running in it?

**URL:** <https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214>\
**Category:** Other MySQL® Questions\
**Tags:** mysql\
**Created:** [April 13, 2022, 9:51am UTC](https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214 "2022-04-13T09:51:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mb1WA](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Mb1WA](https://forums.percona.com/u/Mb1WA)\
**Post date:** [April 13, 2022, 9:51am UTC](https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214/1 "2022-04-13T09:51:21Z")

</div>

Hello Percona team!  
I read the doc for the audit plugin which you have here:  
[https://www.percona.com/doc/percona-server/5.7/management/audit\_log\_plugin.html](https://www.percona.com/doc/percona-server/5.7/management/audit_log_plugin.html)  
In our setup we have prepare/execute commands.  
We can include the execute statements in the audit.  
But its mean that we include everything what we run in execute statements.  
The question is: “Can I exclude “selects” which we run in “execute” statement from the audit somehow?”

---

<div class="post-metadata">

**Author:** ![CTutte](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ctutte/32/1341_2.png) [@CTutte](https://forums.percona.com/u/CTutte)\
**Post date:** [April 13, 2022, 12:24pm UTC](https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214/2 "2022-04-13T12:24:04Z")

</div>

Hi!

You can exclude commands with “audit\_log\_exclude\_commands” parameter as shown on the official doc: audit\_log\_exclude\_commands

In your case , every select inside an execute statement will also be logged even if you exclude “selects”. Reason is shown with this example:  
\<AUDIT\_RECORD  
NAME=“Query”  
RECORD=“33\_2022-04-13T12:17:04”  
TIMESTAMP=“2022-04-13T12:20:06 UTC”  
COMMAND\_CLASS=“execute\_sql”  
CONNECTION\_ID=“5”  
STATUS=“0”  
SQLTEXT=“SELECT 25+35 AS SUM”  
USER=“root[root] @ localhost ”  
HOST=“localhost”  
OS\_USER=“”  
IP=“”  
DB=“”  
/\>

COMMAND\_CLASS column is the value being filtered when excluding commands from the audit log. Since in the above case COMMAND\_CLASS is “execute\_sql” every SQLTEXT will be audited even if it’s a select.

Regards

---

<div class="post-metadata">

**Author:** ![Mb1WA](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Mb1WA](https://forums.percona.com/u/Mb1WA)\
**Post date:** [April 13, 2022, 1:01pm UTC](https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214/3 "2022-04-13T13:01:03Z")

</div>

Yes, This situation I would like to avoid!  
I want to log all insert/updated/deletes only.  
So I need to log all examples where we have COMMAND\_CLASS=“execute\_sql” and SQLTEXT=“insert/update/delete%".  
So the question is how to exclude from audit selects which goes in the execute\_sql?  
I’m sorry, but previous answer don’t answer on this question. ☹

---

<div class="post-metadata">

**Author:** ![CTutte](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ctutte/32/1341_2.png) [@CTutte](https://forums.percona.com/u/CTutte)\
**Post date:** [April 13, 2022, 1:09pm UTC](https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214/4 "2022-04-13T13:09:57Z")

</div>

Hi again,

Sorry if I was not clear enough.

You cannot exclude selects that are inside EXECUTE commands. Either you exclude the entire prepared statement execution, or you log everything.

Regards

---

<div class="post-metadata">

**Author:** ![Mb1WA](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Mb1WA](https://forums.percona.com/u/Mb1WA)\
**Post date:** [April 13, 2022, 1:12pm UTC](https://forums.percona.com/t/can-audit-plugin-include-the-execute-sql-command-but-exclude-selects-running-in-it/15214/5 "2022-04-13T13:12:39Z")

</div>

Hi,  
I had hope that I missed something in the configuration. 🙂  
Thank you very much for your help.
