We extensively use MySQL error logging for proactive diagnostics, MySQL 8 has improved error logging which is capable of sending multiple format (like JSON) logs \u00a0to multiple destinations like Kibana for log processing and analysis. Let’s see how this works:<\/p>\n
mysql> select * from global_variables where VARIABLE_NAME like 'log_error_%';\r\n+---------------------+----------------------------------------+\r\n| VARIABLE_NAME | VARIABLE_VALUE |\r\n+---------------------+----------------------------------------+\r\n| log_error_services | log_filter_internal; log_sink_internal |\r\n| log_error_verbosity | 2 |\r\n+---------------------+----------------------------------------+<\/pre>\nNow that means log events will pass first through log_filter_interval\u00a0<\/em>(built-in filter component) and then through\u00a0log_sink_interval\u00a0<\/em>(built-in log writer component). To configure and enable log_error_services<\/em> you first have to install log component using INSTALL COMPONENT.<\/p>\n
Currently available log components lib \/ plugins:<\/p>\n
\n
- JSON log writer –\u00a0component_log_sink_json.so<\/li>\n
- Built-in log filter and writer – log_filter_interval and log_sink_interval<\/li>\n<\/ul>\n
Step 1 – Load JSON writer first if it’s not loaded:<\/p>\n
INSTALL COMPONENT 'file:\/\/component_log_sink_json';<\/pre>\nStep 2 – Set log_error_services to ‘ log_filter_interval ; log_sink_interval ; log_sink_json ‘ \u00a0(we will set this with MySQL 8 very new feature SET PERSIST<\/strong>)<\/p>\n
SET PERSIST log_error_services = 'log_filter_internal; log_sink_internal; log_sink_json';<\/pre>\nYou may also do same by setting my.cnf<\/p>\n
[mysqld]\r\nlog_error_services='log_filter_internal; log_sink_internal; log_sink_json'<\/pre>\nHow do you order the components in\u00a0log_error_services\u00a0<\/em>is very significant :<\/p>\n
log_filter_internal; log_sink_1; log_sink_2<\/pre>\nThis makes log events to pass through built-in filter, then to first writer and then to second writer. Both writers receive filtered log events. Confirm that to log_error_services value \/ system variable:<\/p>\n
log_sink_1; log_filter_internal; log_sink_2<\/pre>\nSo here, The log events pass through first writer, then to built-in filter, then to second writer.\u00a0The second writer receives filtered events. You can as well configure error logging in way that one log contains messages for all log events and other containing messages of only the subset of log events.<\/p>\n","protected":false},"excerpt":{"rendered":"
We extensively use MySQL error logging for proactive diagnostics, MySQL 8 has improved error logging which is capable of sending multiple format (like JSON) logs \u00a0to multiple destinations like Kibana for log processing and analysis. […]<\/a><\/p>\n<\/div>","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,37],"tags":[5,44],"yoast_head":"\n
Enterprise-class Consulting, 24*7 Support and Remote DBA Services for MySQL, MariaDB, PostgreSQL and ClickHouse<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\n\n\n\t\n\t\n\t\n