首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为Filebeat模块指定管道?

如何为Filebeat模块指定管道?
EN

Stack Overflow用户
提问于 2019-11-01 05:37:20
回答 3查看 3.8K关注 0票数 4

我有web服务器(Ubuntu)与Nginx + PHP。

它有File节拍,它直接将Nginx日志发送到弹性摄取节点(没有Logstash或其他任何东西)。

当我第一次安装它时,我对管道进行了一些自定义,Filebeat创建了这个管道。一个多月来一切都很顺利。

但是我注意到,每次File节拍升级都会导致新管道的创建。目前,我有以下几点:

代码语言:javascript
复制
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: {}

我可以创建新的管道,但是如何告诉(如何配置)File节拍来使用特定的管道?

以下是我尝试过的,但不起作用的东西:

代码语言:javascript
复制
- 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管道。

下面是关于如何配置它的文件节拍说明(但我无法使它工作):https://github.com/elastic/beats/blob/7.4/filebeat/filebeat.reference.yml#L1129-L1130

问题:如何将Filebeat模块配置为使用特定管道?

更新(2019年11月):我提交了相关的bug:https://github.com/elastic/beats/issues/14348

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-11-11 11:23:14

在B拍源代码中,我发现管道ID由以下params解决:

  • 节拍版
  • 模块名
  • 模块的文件集名称
  • 管道文件名

源代码片段如下:

代码语言:javascript
复制
// 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,这需要弹性的官方支持。

目前,管道ID与四个params一起更改。升级B拍时,必须更改elasticsearch中的管道ID。

票数 1
EN

Stack Overflow用户

发布于 2019-11-20 03:22:12

参考/{filebeat-HOME}/module/nginx/access/manifest.yml,也许您应该在/{filebeat-HOME}/modules.d/nginx.yml中设置ingest_pipeline。这个值看起来像一个本地文件。

票数 1
EN

Stack Overflow用户

发布于 2019-11-06 09:08:20

管道可以在inputoutput配置中配置,而不是在模块配置中配置。

因此,在您的配置中有不同的部分,您在问题中显示的部分是用于配置nginx模块。您需要打开filebeat.yml并查找已配置elasticsearchoutput部分,并将管道配置放在那里:

代码语言:javascript
复制
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["elk.slavikf.com:9200"]
  pipeline: filebeat-nginx-access-default

如果您需要能够根据数据的性质使用不同的管道,那么使用管道映射绝对可以这样做。

代码语言:javascript
复制
output.elasticsearch:
  hosts: ["elk.slavikf.com:9200"]
  pipelines:
    - pipeline: "nginx_pipeline"
      when.contains:
        type: "nginx"
    - pipeline: "apache_pipeline"
      when.contains:
        type: "apache"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58654560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档