logstash基于日志文件路径在elasticsearch中创建索引
我想根据路径中包含的字符串创建多个索引 这是我的节拍文件:logstash基于日志文件路径在elasticsearch中创建索引,logstash,elastic-stack,elk,Logstash,Elastic Stack,Elk,我想根据路径中包含的字符串创建多个索引 这是我的节拍文件: filebeat.inputs: - type: log paths: - /home/admin/script_logs/**/*.log ....... ........ 这是我的日志 output { if [log][file][path] =~ /^*scripts*$/ { elasticsearch { hosts =&g
filebeat.inputs:
- type: log
paths:
- /home/admin/script_logs/**/*.log
.......
........
这是我的日志
output {
if [log][file][path] =~ /^*scripts*$/ {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "logstash-scripts-%{+YYYY.MM.dd}"
}
}
else if [log][file][path] =~ /^*system*$/ {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "logstash-system-%{+YYYY.MM.dd}"
}
}
else{
elasticsearch {
hosts => ["http://localhost:9200"]
index => "logstash-normal-%{+YYYY.MM.dd}"
}
}
}
在这里,如果条件([log][file][path]=~/^*脚本*$/和[log][file][path]=~/^*系统*$/)
不起作用,我试图在文件路径中搜索字符串,但它不起作用。
所以谁来帮帮我 你的正则表达式看起来是错误的,我认为它们应该这样写:
/^.*scripts.*$/
&/^.*system.*$/
。如果[log][file][path]{Your output}中的“scripts”,你也可以使用类似于的东西。