Using MySQL 8.0 component_log_filter_dragnet to Filter and Transform Error Logs
This article explains how to install and configure MySQL 8.0's component_log_filter_dragnet, describes its core filter fields and actions, and provides practical examples for customizing error‑log output such as dropping, throttling, setting, and unsetting log entries based on time, priority, error codes, symbols, and subsystems.
MySQL 8.0 includes a component called component_log_filter_dragnet that allows customized filtering and transformation of error‑log entries. The article first shows how to install the component and enable it by setting the global log_error_services variable.
INSTALL COMPONENT 'file://component_log_filter_dragnet'; SET global log_error_services = 'log_filter_dragnet; log_sink_internal';The filtering behavior is controlled through the system variable dragnet.log_error_filter_rules , which accepts rules that specify conditions (fields) and actions (drop, throttle, set, unset). The core fields are:
time : filter based on timestamp, e.g., exclude logs before a certain date.
msg : customize the error message content.
prio : filter by priority levels such as ERROR, WARNING, NOTE.
err_code/SQL_state : filter by specific error codes or SQL state values.
err_symbol : filter using the symbolic name of the error.
subsystem : filter by subsystem like Server or InnoDB.
The four possible actions are:
drop : remove the matching log entry.
throttle : limit the frequency of matching entries.
set : modify field values (e.g., change msg or err_code ).
unset : reset a field to its default state.
Several concrete examples illustrate how to use these fields and actions:
Time filter (drop entries before 2023‑01‑01):
set global dragnet.log_error_filter_rules='if time <'2023-01-01' then drop .';Priority filter (drop warnings):
set global dragnet.log_error_filter_rules='if prio==warning then drop .';Error‑code filter (drop a specific code):
set global dragnet.log_error_filter_rules='if err_code==MY-010926 then drop .';Set a new error code:
set global dragnet.log_error_filter_rules='if err_code==MY-010926 or err_code==MY-013360 then set err_code=1234567890 .';Customize the message field:
set global dragnet.log_error_filter_rules='if err_code==MY-010926 or err_code==MY-013360 then set msg='你来看哦,没有了哦!!!' .';Symbol‑based message customization:
set global dragnet.log_error_filter_rules='if err_symbol==''ER_SERVER_WARN_DEPRECATED'' or err_symbol==''ER_ACCESS_DENIED_ERROR_WITH_PASSWORD'' then set msg='你来看哦,没有了哦!!' .';Subsystem filter (drop all Server errors):
set global dragnet.log_error_filter_rules='if subsystem==''Server'' then drop .';Unset action (reset message to default):
set global dragnet.log_error_filter_rules='if err_code==MY-010926 or err_code==MY-013360 then unset msg .';Throttle action (limit to two entries total or two per minute):
set global dragnet.log_error_filter_rules='if err_code==MY-010926 or err_code==MY-013360 then throttle 2 .'; set global dragnet.log_error_filter_rules='if err_code==MY-010926 or err_code==MY-013360 then throttle 2/60 .';Complex conditional examples show how to apply different set actions for different error codes, resulting in customized messages for each.
The article concludes that the component provides flexible, rule‑based control over MySQL error logging, enabling administrators to suppress, transform, or limit log entries according to operational needs.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.