input{
tcp {
mode => "server"
host => "0.0.0.0"
port => 5000
codec => json_lines
type=> "A"
}
tcp {
mode => "server"
host => "0.0.0.0"
port => 4999
codec => json_lines
type=> "B"
}
}
filter{
if[type] == "A"{
if([message] =~ "^(?!.*?登录日志).*$") {
### 丢弃
drop{}
}
}
}
output{
if[type] == "A"{
elasticsearch{
hosts=>["192.168.4XX.XX:9200"]
index => "A-%{+YYYY.MM.dd}"
}
}
if[type] == "B"{
elasticsearch{
hosts=>["192.168.XX.XX:9200"]
index => "B-%{+YYYY.MM.dd}"
}
}
}
配置背景:1.从两台服务器上分别获取日志 且日志索引不同(为A,B)
2.A服务日志进行拦截 如果没有带"登录日志"字样的日志丢弃
知识点 :1 判断语句 if写法
2 过滤器使用
3 通过日期生成相同业务的不同索引(可以通过index template查询)