# Defining rules for audit log filter component (v8.0 / 8.4)

**URL:** <https://forums.percona.com/t/defining-rules-for-audit-log-filter-component-v8-0-8-4/36276>\
**Category:** Percona Server for MySQL\
**Created:** [January 22, 2025, 9:08am UTC](https://forums.percona.com/t/defining-rules-for-audit-log-filter-component-v8-0-8-4/36276 "2025-01-22T09:08:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![audit\_4852](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@audit\_4852](https://forums.percona.com/u/audit_4852)\
**Post date:** [January 22, 2025, 9:08am UTC](https://forums.percona.com/t/defining-rules-for-audit-log-filter-component-v8-0-8-4/36276/1 "2025-01-22T09:08:05Z")

</div>

Dear Percona community,

I am struggling to configure the rules for the audit log filter component. I would like to filter events in a way that only certain sql commands are logged.  
This is what I have so far:  
“filter”: {  
“class”:  
{  
“name”: “query”,  
“event”: {  
“name”: “start”  
}  
}  
}

This filter successfully logs all query\_start events in the class query. I now want to add functionality so that only the following sql commands are logged:  
SELECT  
CREATE TABLE  
DROP TABLE  
I tried to do this by accessing the “sql\_command”-field but could not get it to work.  
Could someone help me with this? Thank you all 🙂

---

<div class="post-metadata">

**Author:** ![dba\_S4dscjz](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dba\_S4dscjz](https://forums.percona.com/u/dba_S4dscjz)\
**Post date:** [April 23, 2025, 11:05am UTC](https://forums.percona.com/t/defining-rules-for-audit-log-filter-component-v8-0-8-4/36276/2 "2025-04-23T11:05:23Z")

</div>

Hell @audit_4852,

I’ve just started a new discussion [Write audit\_log\_filter definitons](https://forums.percona.com/t/write-audit-log-filter-definitons/37704) about writing rules for this component. In your case I think something like this can help you :

```auto
{
  "filter": {
    "class": [
      {
        "name": "query",
        "event": {
          "name": "start",
          "log": {
              "or": [
                { "field": { "name": "sql_command_id", "value": "select"} },
                { "field": { "name": "sql_command_id", "value": "create_table"} },
                { "field": { "name": "sql_command_id", "value": "drop_table"} }
              ]
          }
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![audit\_4852](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@audit\_4852](https://forums.percona.com/u/audit_4852)\
**Post date:** [May 7, 2025, 8:26am UTC](https://forums.percona.com/t/defining-rules-for-audit-log-filter-component-v8-0-8-4/36276/3 "2025-05-07T08:26:04Z")

</div>

Hello @dba_S4dscjz,

thanks for your reply 🙂  
This did indeed solve my problem

---

<div class="post-metadata">

**Author:** ![Wayne\_Leutwyler](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/wayne_leutwyler/32/20829_2.png) [@Wayne\_Leutwyler](https://forums.percona.com/u/Wayne_Leutwyler)\
**Post date:** [October 14, 2025, 11:41am UTC](https://forums.percona.com/t/defining-rules-for-audit-log-filter-component-v8-0-8-4/36276/4 "2025-10-14T11:41:12Z")

</div>

I have posted a Blog about writing the rules. You might find the example helpful. You can read the blog here: [Audit Log Filters Part II | Percona Community](https://percona.community/blog/2025/10/08/audit-log-filters-part-ii/)
