系統(tǒng)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 遠程則需要另外創(chuàng)建一個用戶
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 是否正確 不正確則執(zhí)行
source /etc/profile
6.重新運行l(wèi)ogstash
cd /usr/share/logstash
./bin/logstash -f conf/logstash.conf
7.測試
模仿kafka寫一個rabbitmq發(fā)送測試消息 logstash的kafka配置
8.結果
其他結果與kafka例子同