8.4.6 The Audit Message Component (original) (raw)

This section describes theaudit_api_message_emit_udf() function implemented by theaudit_api_message_emit component.

mysql> SELECT audit_api_message_emit_udf('component_text',  
                                         'producer_text',  
                                         'message_text',  
                                         'key1', 'value1',  
                                         'key2', 123,  
                                         'key3', NULL) AS 'Message';  
+---------+  
| Message |  
+---------+  
| OK      |  
+---------+  

Additional information:
Each audit plugin that receives an event posted byaudit_api_message_emit_udf() logs the event in plugin-specific format. For example, theaudit_log plugin (seeSection 8.4.5, “MySQL Enterprise Audit”) logs message values as follows, depending on the log format configured by theaudit_log_format system variable:

{  
  ...  
  "class": "message",  
  "event": "user",  
  ...  
  "message_data": {  
    "component": "component_text",  
    "producer": "producer_text",  
    "message": "message_text",  
    "map": {  
      "key1": "value1",  
      "key2": 123,  
      "key3": null  
    }  
  }  
}  
<AUDIT_RECORD>  
 ...  
 <NAME>Message</NAME>  
 ...  
 <COMMAND_CLASS>user</COMMAND_CLASS>  
 <COMPONENT>component_text</COMPONENT>  
 <PRODUCER>producer_text</PRODUCER>  
 <MESSAGE>message_text</MESSAGE>  
 <MAP>  
   <ELEMENT>  
     <KEY>key1</KEY>  
     <VALUE>value1</VALUE>  
   </ELEMENT>  
   <ELEMENT>  
     <KEY>key2</KEY>  
     <VALUE>123</VALUE>  
   </ELEMENT>  
   <ELEMENT>  
     <KEY>key3</KEY>  
     <VALUE/>  
   </ELEMENT>  
 </MAP>  
</AUDIT_RECORD>  
<AUDIT_RECORD  
  ...  
  NAME="Message"  
  ...  
  COMMAND_CLASS="user"  
  COMPONENT="component_text"  
  PRODUCER="producer_text"  
  MESSAGE="message_text"/>  

Note
Message events logged in old-style XML format do not include the key-value map due to representational constraints imposed by this format.
Messages posted byaudit_api_message_emit_udf() have an event class ofMYSQL_AUDIT_MESSAGE_CLASS and a subclass of MYSQL_AUDIT_MESSAGE_USER. (Internally generated audit messages have the same class and a subclass of MYSQL_AUDIT_MESSAGE_INTERNAL; this subclass currently is unused.) To refer to such events inaudit_log filtering rules, use aclass element with aname value of message. For example:

{  
  "filter": {  
    "class": {  
      "name": "message"  
    }  
  }  
}  

Should it be necessary to distinguish user-generated and internally generated message events, test thesubclass value againstuser or internal.
Filtering based on the contents of the key-value map is not supported.
For information about writing filtering rules, seeSection 8.4.5.7, “Audit Log Filtering”.