logstash 在filebeat中添加额外字段

uajslkp6  于 2023-03-16  发布在  Logstash
关注(0)|答案(1)|浏览(328)
filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

- type: log

# Change to true to enable this input configuration.
enabled: true

# Paths that should be crawled and fetched. Glob based paths.
paths:
   - {some path}
fields:
   target_index: import-export-logger
   build_version: $build_version

这里我想在字段中添加build_version。我的build_version存储在每个服务器上的一个文件中。
filebeat可以读取文件并在字段中添加build_version吗?

yr9zkbsy

yr9zkbsy1#

如果需要添加additional fields,可以将以下行添加到filebeat.yml中

processors:
- add_fields:
    target: ''
    fields:
      field_name: field_value

https://www.elastic.co/guide/en/beats/filebeat/current/add-fields.html
如果需要解析日志并根据数据添加动态字段,则需要从日志中摄取和获取信息。

processors:
  - dissect:
      tokenizer: "%{key1} %{key2}"
      field: "message"
      target_prefix: ""

上述处理器将解析message字段,并创建key1key2字段
https://www.elastic.co/guide/en/beats/filebeat/current/dissect.html
注:filebeat中的解剖类似于logstash中的grok

相关问题