在使用logstash和filebeat的elasticsearch中,选择文件夹中的每个文件作为单个日志条目

cunj1qz1  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(1)|浏览(619)

我有一个要求,我的麋鹿必须选择一个文件夹中的每个文件作为一个单一的日志。我有一个父\u文件夹/其中将为运行创建一个文件夹\u文件夹/其中创建了几种类型的日志文件。我需要将每个文件作为单个日志推入ElasticSearch。

Folder Structure
parent_folder/run1/file1.log
parent_folder/run1/file2.err
parent_folder/run1/file3.diff
              ...
parent_folder/run2/file1.log
parent_folder/run2/file2.err
parent_folder/run2/file3.diff

ElasticSearch应该有

doc1{
message: the content of parent_folder/run1/file1.log
}
doc2{
message: the content of parent_folder/run1/file2.err
}
doc3{
message: the content of parent_folder/run2/file2.err
}
... so on

像parent\u folder/run2/file2.err这样的文件只写一次,不会再更改或触摸,无需监视更改。谢谢

rjzwgtxy

rjzwgtxy1#

使用filebeat,可以使用多行模式。在日志文件中找到一个不匹配的模式,然后在filebeat配置中进行如下配置。

multiline.pattern: 'never_matching_pattern'
 multiline.match: after

参考文献:https://discuss.elastic.co/t/filebeat-send-the-entire-logfile-as-a-single-message/118265

相关问题