系统ubuntu16.04
1.elk的搭建
2.rabbitmq的安装与配置
3.修改logstash配置文件
cd /usr/share/logstash/conf
sudo vim logstash.conf
input{
rabbitmq {
host => "192.168.1.200"
#连接本地的rabbitmq可以不用设置user和password 默认guest 远程则需要另外创建一个用户
user => "admin"
password => "admin"
######################
queue => "topic_log_error"
durable => true
codec => "plain"
type => "error"
}
rabbitmq {
host => "192.168.1.200"
#与上同
user => "admin"
password => "admin"
queue => "topic_log_info"
codec => "plain"
durable => true
type => "info"
}
}
filter {
if ([message]== "")
{
drop {}
}
}
output {
if [type] == "error" {
elasticsearch {
hosts => [ "192.168.1.200:9200"]
index => "logstash-error"
}
}
if [type] == "info" {
elasticsearch {
hosts => [ "192.168.1.200:9200"]
index => "logstash-info"
}
}
stdout{
codec => rubydebug
}
}
保存退出
4.切换到es用户 su es
5.查看java -version 是否正确 不正确则执行
source /etc/profile
6.重新运行logstash
cd /usr/share/logstash
./bin/logstash -f conf/logstash.conf
7.测试
模仿kafka写一个rabbitmq发送测试消息 logstash的kafka配置
8.结果
其他结果与kafka例子同