我正在尝试使用elasticsearch logstash和kibana为一组Windows和Linux服务器构建集中式日志记录系统。我的输入将是来自两个系统的系统日志(单个输入流)。我试图了解是否有使用grok并匹配模式的方法,然后基于此将日志放入不同的索引(一个用于Windows日志,另一个用于linux日志)
任何方向的帮助将不胜感激。
谢谢,
最佳答案
您可以根据日志来自哪个系统来分配“类型”,然后在输出中使用该类型。
下面是配置:
input{
file{
path =>"path/to/system1_log_file"
type =>"sys1logs"
}
file{
path =>"path/to/system2_log_files"
type =>"sys2logs"
}
}
output{
if[type]=="sys1logs"{
#output to sys1 index
elasticsearch{host => localhost
index => "sys1"
}
}
if[type]=="sys2logs"{
#output to sys2 index
elasticsearch{host => localhost
index =>"sys2"
}
}
}
关于regex - 基于Logstash中的模式匹配创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31277641/