我有带 Nginx + PHP 的网络服务器 (Ubuntu)。
它有 Filebeat,它直接将 Nginx 日志发送到 Elastic 摄取节点(没有 Logstash 或其他任何东西)。
当我第一次安装它时,我对 Filebeat 创建的管道进行了一些自定义。
在一个月左右的时间里,一切都很好。
但我注意到,每次 Filebeat 升级都会导致新管道的创建。目前我有这些:
filebeat-7.3.1-nginx-error-pipeline: {},
filebeat-7.4.1-nginx-error-pipeline: {},
filebeat-7.2.0-nginx-access-default: {},
filebeat-7.3.2-nginx-error-pipeline: {},
filebeat-7.4.1-nginx-access-default: {},
filebeat-7.3.1-nginx-access-default: {},
filebeat-7.3.2-nginx-access-default: {},
filebeat-7.2.0-nginx-error-pipeline: {}
我可以创建新的管道,但我如何告诉(如何配置)Filebeat 使用特定的管道?
这是我试过的,但它不起作用:
- module: nginx
# Access logs
access:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/var/log/nginx/*/*access.log"]
# Convert the timestamp to UTC
var.convert_timezone: true
# The Ingest Node pipeline ID associated with this input. If this is set, it
# overwrites the pipeline option from the Elasticsearch output.
output.elasticsearch.pipeline: 'filebeat-nginx-access-default'
pipeline: 'filebeat-nginx-access-default
它仍然使用 filebeat-7.4.1-nginx-error-pipeline
管道。
这是关于如何配置它的 Filebeat 说明(但我无法让它工作): https://github.com/elastic/beats/blob/7.4/filebeat/filebeat.reference.yml#L1129-L1130
问题: 如何配置 Filebeat 模块以使用特定管道?
更新(2019 年 11 月):我提交了相关错误:https://github.com/elastic/beats/issues/14348
最佳答案
在beats源码中,我发现pipeline ID是通过以下params设置的:
- 节拍版本
- 模块名称
- 模块的文件集名称
- 管道文件名
源代码片段如下:
// formatPipelineID generates the ID to be used for the pipeline ID in Elasticsearch
func formatPipelineID(module, fileset, path, beatVersion string) string {
return fmt.Sprintf("filebeat-%s-%s-%s-%s", beatVersion, module, fileset, removeExt(filepath.Base(path)))
}
所以不能分配管道ID,需要elastic官方支持。
目前,管道 ID 随四个参数一起更改。升级节拍时,您必须更改 elasticsearch 中的管道 ID。
关于elasticsearch - 如何为 Filebeat Nginx 模块指定管道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58654560/