gpt4 book ai didi

elasticsearch - Logstash 是否可以将相同的内容从日志文件推送到 ElasticSearch

转载 作者:行者123 更新时间:2023-12-03 02:12:01 24 4
gpt4 key购买 nike

logstash config 将日志文件设置为输入源,然后将内容发送到 ElasticSearch .input部分如下

input{
file{
path => "/data/logs/backend.log*"
start_position => "beginning"
}
}
然后日志文件将按大小滚动,这意味着最初的日志文件名是 backend.log ,当文件达到10M大小时,将其重命名为 backend.log.1 ,并创建一个新的空 backend.log 来记录内容。
所以问题是 logstash将从 backend.log.1 发送内容到es服务器?或者是 ElasticSearch能够区分 backend.log.1 中的内容已经收到,尽管这似乎效率不高。

最佳答案

file输入文档包含一整段关于它如何处理rotation

File rotation is detected and handled by this input, regardless of whether the file is rotated via a rename or a copy operation. To support programs that write to the rotated file for some time after the rotation has taken place, include both the original filename and the rotated filename (e.g. /var/log/syslog and /var/log/syslog.1) in the filename patterns to watch (the path option).


由于 tail模式是默认值,您的 path参数应该确保使用 glob 模式来捕获所有文件,就像你做的那样。所以你都准备好了。尾随快乐!

关于elasticsearch - Logstash 是否可以将相同的内容从日志文件推送到 ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64477231/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com