Logstash收集MySQL慢查询日志

说明

1
2
ELK服务器IP:192.168.10.30
Mysql服务器IP:192.168.10.203
1、修改Logstash服务端配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
vim /etc/logstash/test203_mysql_slow_query.conf

input {
#test203_mysql_slow_query
rabbitmq {
host => "192.168.10.30"
port => 5672
key => "test203_mysql_slow_query"
user => "jishubu"
password => "0066jishu"
exchange => "amq.direct"
exchange_type => "direct"
}


}


output {
if [type] == "test203_mysql_slow_query" {
elasticsearch {
hosts => "192.168.10.30:9200"
index => "test203_mysql_slow_query-%{+YYYY.MM.dd}"
}
}

}
2、检查配置文件是否正确
1
/a01/apps/logstash/bin/logstash -t -f /etc/logstash/
3、修改logstash客户端配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
vim /etc/logstash/test203_mysql_slow_query.conf

input {
#test203_mysql_slow_query
file {
path => "/data1/mysql/data/slow-query.log"
type => "test203_mysql_slow_query"
}

}


output {
if [type] == "test203_mysql_slow_query" {
rabbitmq {
host => "192.168.10.30"
port => 5672
key => "test203_mysql_slow_query"
user => "jishubu"
password => "0066jishu"
exchange => "amq.direct"
exchange_type => "direct"
}
}
}
4、检查配置文件是否正确
1
/data1/logstash/bin/logstash -t -f /etc/logstash/
5、重启服务端logstash
1
systemctl restart logstash
6、启动客户端logstash
1
service logstash start
7、随便去插入几条消息到mysql的慢查询日志里边,让logstash服务端能抓取到日志
8、去kibana创建index

PWQs58.png

PWQ6PS.png

PWQc8g.png

博主QQ:1012405802
技术交流QQ群:830339411
版权声明:网站内容有原创和转载,如有侵权,请联系删除,谢谢!!
感谢打赏,93bok因你们而精彩!!(支付宝支持花呗)
0%