如何为 Filebeat Nginx 模块指定管道?
How to specify pipeline for Filebeat Nginx module?
我有网络服务器 (Ubuntu) 和 Nginx + PHP.
它有 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
管道可以在您的 input
或 output
配置中配置,而不是在模块配置中配置。
因此在您的配置中您有不同的部分,您在问题中显示的部分用于配置 nginx
模块。您需要打开 filebeat.yml
并查找您配置 elasticsearch
的 output
部分并将管道配置放在那里:
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["elk.slavikf.com:9200"]
pipeline: filebeat-nginx-access-default
如果您需要能够根据数据的性质使用不同的管道,您绝对可以使用 pipeline mappings:
output.elasticsearch:
hosts: ["elk.slavikf.com:9200"]
pipelines:
- pipeline: "nginx_pipeline"
when.contains:
type: "nginx"
- pipeline: "apache_pipeline"
when.contains:
type: "apache"
在beats源码中,我发现pipeline ID是由以下参数决定的:
- 节拍版本
- 模块名称
- 模块的文件集名称
- 管道文件名
源代码片段如下:
// 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)))
}
所以不能分配pipeline ID,需要elastic官方支持
目前,管道 ID 随四个参数一起更改。升级 beats 时必须更改 elasticsearch 中的管道 ID。
参考/{filebeat-HOME}/module/nginx/access/manifest.yml
,
也许你应该在 /{filebeat-HOME}/modules.d/nginx.yml
中设置 ingest_pipeline
。
该值似乎是一个本地文件。
我有网络服务器 (Ubuntu) 和 Nginx + PHP.
它有 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
管道可以在您的 input
或 output
配置中配置,而不是在模块配置中配置。
因此在您的配置中您有不同的部分,您在问题中显示的部分用于配置 nginx
模块。您需要打开 filebeat.yml
并查找您配置 elasticsearch
的 output
部分并将管道配置放在那里:
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["elk.slavikf.com:9200"]
pipeline: filebeat-nginx-access-default
如果您需要能够根据数据的性质使用不同的管道,您绝对可以使用 pipeline mappings:
output.elasticsearch:
hosts: ["elk.slavikf.com:9200"]
pipelines:
- pipeline: "nginx_pipeline"
when.contains:
type: "nginx"
- pipeline: "apache_pipeline"
when.contains:
type: "apache"
在beats源码中,我发现pipeline ID是由以下参数决定的:
- 节拍版本
- 模块名称
- 模块的文件集名称
- 管道文件名
源代码片段如下:
// 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)))
}
所以不能分配pipeline ID,需要elastic官方支持
目前,管道 ID 随四个参数一起更改。升级 beats 时必须更改 elasticsearch 中的管道 ID。
参考/{filebeat-HOME}/module/nginx/access/manifest.yml
,
也许你应该在 /{filebeat-HOME}/modules.d/nginx.yml
中设置 ingest_pipeline
。
该值似乎是一个本地文件。