Rsyslog : MySQL ErrorログとSlow-Queryの取り込するみための設定
# vi /etc/rsyslog.d/80-mysql.conf
 #variables required for non-syslog log file forwarding – mysql error
 #edit on your location
 input(type=”imfile”
 File=”/var/log/mysqld.log”
 Tag=”mysqld-errors”
 Severity=”error”
 Facility=”local7″)
 input(type=”imfile”
 File=”/var/log/mysql-slow.log”
 Tag=”mysql-slow”
 Severity=”notice”
 Facility=”local7″)
 ###### Creates a template for each log file in the Logentries UI
 ### logic to apply the relevant templates to the different log files
 if $programname == ‘mysqld-errors’ then /var/log/plura/ceelog-127.0.0.1.log;CEETemplate
 :programname, isequal, “mysqld-errors” ~
 if $programname == ‘mysql-slow’ then /var/log/plura/ceelog-127.0.0.1.log;CEETemplate
 :programname, isequal, “mysql-slow” ~
rsyslog restart
# systemctl restart rsyslog
# wget https://repo.plura.io/v5/module/rsyslog/80-mysql.conf
# curl https://repo.plura.io/v5/module/rsyslog/80-mysql.conf -o /etc/rsyslog.d/80-mysql.conf
# vi /etc/my.cnf
[mysqld]
slow_query_log = 1
slow_query_log_file = /var/log/mysql-slow.log
long_query_time = 3
# touch /var/log/mysql-slow.log
# chown mysql.mysql /var/log/mysql-slow.log
# ls -aZ /var/log/mysql*
# systemctl restart mysqld
mysql> show variables like ‘slow_query_%’;
Error又はSlow Query発生後、システムログからMySQLに対するログを確認
ログ例 : 全ログ > システム
外部参考サイト
https://www.rsyslog.com/doc/v8-stable/configuration/modules/imfile.html