【问题标题】:Define field type with add_fields processor in filebeat.yml?在 filebeat.yml 中使用 add_fields 处理器定义字段类型?
【发布时间】:2020-02-13 21:24:27
【问题描述】:

查看有关添加字段的this 文档,我看到filebeat 可以按名称和值添加任何自定义字段,这些字段将附加到Filebeat 推送到Elasticsearch 的每个文档中。

这是在 filebeat.yml 中定义的:

processors:
- add_fields:
    target: project
    fields:
      name: myproject
      id: '574734885120952459'

有没有办法,严格从 filebeat.yml,给这里添加的字段一个“类型”?例如,我可以分配“名称”来键入“关键字”吗?

【问题讨论】:

    标签: elasticsearch kibana elastic-stack filebeat


    【解决方案1】:

    我看到完成的唯一方法不涉及 filebeat.yml,而是在 filebeat 目录中创建一个自定义 fields.yml 文件(这都适用于任何节拍),并在“节拍”下指定字段和类型键。

    例如,如果上面的字段“id”在 filebeat.yml 中声明,并且我们希望它是“关键字”类型的自定义字段,我们将执行以下操作:

    将 fields.yml 复制到 filebeat 目录中的 my_filebeat_fields.yml 文件。 在 my_filebeat_fields 中,添加此部分:

    - key: beat
      anchor: beat-common
      title: Beat
      description: >
        Contains common beat fields available in all event types.
      fields:
        # your customization begins here:
        - name: id
        - type: keyword
    

    然后执行以下操作以使用这个新的自定义字段文件:

    修改这部分 filebeat.yml 以包含:

    #==================== Elasticsearch template setting ==========================
    
    setup.template.name: "filebeat-*"
    setup.template.fields: "my_filebeat_fields.yml"
    setup.template.overwrite: true
    

    然后按照this guide,以适合您环境的任何方法将模板加载到弹性中。

    (假设一切都是 7.x 版)

    编辑:

    显然在 filebeat.yml 文件中设置“setup.template.append_fields”选项也可以,但我没有探索过。

    https://www.elastic.co/guide/en/beats/filebeat/current/configuration-template.html

    【讨论】:

    • 为什么键必须是“节拍”?你有这方面的参考吗?
    猜你喜欢
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    • 2010-09-08
    • 2011-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多