我有使用Nginx + PHP的Web服务器(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模块以使用特定管道?
可以在input
或output
配置中配置管道,而不能在模块之一中配置管道。
因此在您的配置中有不同的部分,您在问题中显示的部分是用于配置nginx
模块的。您需要打开filebeat.yml
并在配置了output
的位置寻找elasticsearch
部分,然后在此处放置管道配置:
#-------------------------- 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"