英文:
Making Filebeat start with old files offsets using old registry
问题
我正在运行一个使用prima/filebeat镜像的docker容器,其中包含Filebeat(以前称为"logstash-forwarder")。
日志文件位于加载到容器中的卷中,我希望能够删除容器并重新运行它,而不会重新将日志发送到logstash。
我尝试将/.filebeat注册表文件作为卷加载,以便在启动时重新加载它,但我得到了以下错误:
2016/02/03 13:47:29.107457 file_other.go:39: ERR Rotate error: rename /.filebeat.new /.filebeat: device or resource busy
2016/02/03 13:47:29.107788 registrar.go:105: ERR Writing of registry returned error: rename /.filebeat.new /.filebeat: device or resource busy. Continuing..
有人知道如何实现这样的操作吗?
英文:
I'm running Filebeat (used to be know as "logstash-forwarder") on a docker container using prima/filebeat image.
The log files are located in a volume loaded to the container and I want to be able to remove the container and rerun it without it re-sending the logs to the logstash.
I tried to load the /.filebeat registry file as a volume so it will be reloaded on startup but all I get are these errors:
2016/02/03 13:47:29.107457 file_other.go:39: ERR Rotate error: rename /.filebeat.new /.filebeat: device or resource busy
2016/02/03 13:47:29.107788 registrar.go:105: ERR Writing of registry returned error: rename /.filebeat.new /.filebeat: device or resource busy. Continuing..
Does anybody happen to know how to do such a thing?
答案1
得分: 1
使用Filebeat版本1.2.3(其他版本可能相同,版本1.3几天前刚发布,我还没有尝试过)时,您需要指定注册表文件的路径。注册表文件是Filebeat保存其读取偏移量的文件(换句话说,它正在处理的日志文件中的当前读取点)。
您需要在filebeat.yml
文件的prospectors
部分之后指定注册表路径。
类似于:
filebeat:
prospectors:
-
document_type: wildfly-server
input_type: log
paths:
- /path/to/my/log.log
multiline:
pattern: 'your pattern'
negate: true
match: after
registry_file: /data/.filebeat
logging:
level: debug
to_syslog: true
output:
logstash:
hosts:
- "127.0.0.1:5000"
然后,在您的Docker Compose文件中,您需要挂载一个指向registry_file
路径的卷。类似于:
filebeat:
image: prima/filebeat:latest
volumes:
- /data/filebeat:/data
hostname: qa
然后,您应该在主机上看到位于/data/filebeat
文件夹中的.filebeat
文件。
英文:
With Filebeat version 1.2.3 (other versions may be the same, version 1.3 just came out a few days ago and I've not tried it yet) you will need to specify the path to the registry file. The registry file is the file where Filebeat keeps it read offset (in other words, the current read point in the log(s) file(s) it is processing).
You need to specify the registry path in your filebeat.yml
file, after the prospectors
section.
Something like:
filebeat:
prospectors:
-
document_type: wildfly-server
input_type: log
paths:
- /path/to/my/log.log
multiline:
pattern: 'your pattern'
negate: true
match: after
registry_file: /data/.filebeat
logging:
level: debug
to_syslog: true
output:
logstash:
hosts:
- "127.0.0.1:5000"
Then in your docker compose file you need to mount a volume pointing to your registry_file
path. Something like:
filebeat:
image: prima/filebeat:latest
volumes:
- /data/filebeat:/data
hostname: qa
Then you should see in the host the .filebeat
file located in the /data/filebeat
folder.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论