Stop audit_record.command_class ping from recording to logs


I cant seem to find any information about this issue in the audit log documentation so i wanted to ask the community in order to get an idea if anyone else has had this problem.

We are currently monitoring DB activity using AuditLog, however, when we go to view the data on elastic we find that there are a lot of entries for the following:

audit_record.command_class ping

We don’t need this to be recorded at all as it is just bloating the logging up (admittedly not by much, but it seems pointless to keep something we have no use for).

I know you can exlcude commands from logging but I believe ping is something that is carried out by MySQL itself so im unsure how to exclude this.

I would appreciate the help

Thanks in advance!

Hi @simonnutsey98
I think this ping command is being issues by your MySQL Connector (See the " Validating Connections" section here).

Out of curiosity, have you tried excluding the ping command in your audit log?

SET GLOBAL audit_log_exclude_commands='ping';

You may need to add a comma separated list if you already have other commands being excluded.

HI @Mauricio_Cacho

Ace! - Ill try this and mark this as the solution if it fixes things for me! :slight_smile:


The better option is to just turn off ping in your application. It is somewhat useless. Consider these code paths:

  • mysql_ping() returns false
  • log failure, wait 10s, try again
  • execute query, returns failure
  • log failure, wait 10s, try again
  • execute query, query succeeds
  • mysql_ping, returns true
  • execute query, query succeeds

Do you see how in cases 1, 2, and 4 the ping is irrelevant? You should skip the ping and just execute the query directly. You’ll get the same result as if you used ping but without the extra wasted CPU/Network.