场景
logstash采集2个数据源A和B,A数据源的入kafka,B数据源的都入es。
示例
语法
Input{
file { path => a type => A }
file { path => b type => B }
}
output {
if [type] == "A" {
kafka {...}
}
if [type] == "B" {
es {...}
}
}
我的实现的场景:
bin/logstash -e 'input{
file{
type => "normal"
path => "/data/log/test/abc*.log"
start_position => beginning
exclude => "*abc*.log"
}
file{
type => "error"
path => "/data/log/test/*error*.log"
start_position => beginning
}
}
output{
if [type] == "error" {
kafka{
bootstrap_servers => "127.0.0.1:9092,127.0.0.1:9092"
topic_id => "loga"
}
}
stdout{codec=>rubydebug}
}'
ok,完美解决。