# Audit plugin - audit\_log\_policy=query for some users but login for all users - possible?

**URL:** <https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368>\
**Category:** Other MySQL® Questions\
**Created:** [April 12, 2023, 9:56pm UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368 "2023-04-12T21:56:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![darren](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@darren](https://forums.percona.com/u/darren)\
**Post date:** [April 12, 2023, 9:56pm UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368/1 "2023-04-12T21:56:57Z")

</div>

Hi,  
I am interested in figuring out a way to log all connection attempts for all users but only queries from users not in the `audit_log_exclude_accounts` list. Would that be at all possible?

cheers  
Darren

---

<div class="post-metadata">

**Author:** ![Agustin\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/agustin_g/32/14111_2.png) [@Agustin\_G](https://forums.percona.com/u/Agustin_G)\
**Post date:** [April 13, 2023, 2:59am UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368/2 "2023-04-13T02:59:07Z")

</div>

Hi Darren,  
Welcome to the forum!

This is not possible. The filters you use will apply in all cases, and it’s not possible to selectively have them apply to only some of the users in some cases, and some in others.  
You can check the online documentation for more info on this:

> **[Percona Server for MySQL](https://docs.percona.com/percona-server/8.0/management/audit_log_plugin.html#filter-methods)**
>
> Documentation

Best,  
Agustín.

---

<div class="post-metadata">

**Author:** ![Pep\_Pla](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/pep_pla/32/9735_2.png) [@Pep\_Pla](https://forums.percona.com/u/Pep_Pla)\
**Post date:** [April 13, 2023, 5:53am UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368/3 "2023-04-13T05:53:13Z")

</div>

Hi @darren

As @Agustin_G pointed, you can’t achieve the desired effect using the audit plugin only, but I think you could get the same results using the audit plugin and logging the events in syslog. Then apply additional filters in syslog.

This is a bit more complex, but it should work.

Pep

---

<div class="post-metadata">

**Author:** ![darren](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@darren](https://forums.percona.com/u/darren)\
**Post date:** [April 13, 2023, 7:23am UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368/4 "2023-04-13T07:23:25Z")

</div>

Thank you both Agustin and Pep,  
Pep, with your solution would I need to log “All” logins and queries from all users without excluding anything then do the filtering in syslog? For systems which run tens of thousands of queries per second from an application user but a handful a minute for anything else it would cause a huge influx in logging should I remove the application user which is my concern in that case. Would that also be your understanding?

Darren

---

<div class="post-metadata">

**Author:** ![Pep\_Pla](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/pep_pla/32/9735_2.png) [@Pep\_Pla](https://forums.percona.com/u/Pep_Pla)\
**Post date:** [April 13, 2023, 8:08am UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368/5 "2023-04-13T08:08:21Z")

</div>

Hi @darren

Auditing has a performance impact for sure. In this case, most of the impact should go to CPU usage. There are multiple ways to reduce this impact. It depends on how you perform the filtering.

My recommendation is to make some tests, as there are several syslog implementations available that provide different tuning options.

Two alternatives that could be used (in no particular order):

- Clone the network switch port to another port and use a dedicated server with a tool like Wireshark to analyze the traffic and generate the log. (Will not generate audit information for local connections)
- Use ProxySQL and use it to perform the audit.

I still think that the combination of audit plugin + syslog is the better option, but you can use any of these alternatives if performance is a problem.

Pep

---

<div class="post-metadata">

**Author:** ![darren](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@darren](https://forums.percona.com/u/darren)\
**Post date:** [April 13, 2023, 7:12pm UTC](https://forums.percona.com/t/audit-plugin-audit-log-policy-query-for-some-users-but-login-for-all-users-possible/21368/6 "2023-04-13T19:12:39Z")

</div>

Thank you Pep. Appreciate you sharing your thoughts and suggestions. Have a great rest of your week.

Darren
