filebeat-74-codecformat-变量配置方法

12次阅读

共计 872 个字符,预计需要花费 3 分钟才能阅读完成。

filebeat 7.4 codec.format 变量配置方法

无论你是使用哪个版本的 filebeat, 当你的 output.xx 中需要配置 code.cormat 的变量,最开始是从官网上查询,后来发现有个更方便的方法;
重点就是 codec.format 中的变量都是从已经生成 json 的对象中获取,就是信息和元数据都已经生成好准备 output 目标;

  • 打印 outputjson数据
{
    "@timestamp":"2019-11-19T06:42:34.222Z",
    "@metadata":{
        "beat":"filebeat",
        "type":"_doc",
        "version":"7.4.2",
        "topic":"xxx-click"
    },
    "host":{"name":"eeexx-asdddd"},
    "agent":{
        "version":"7.4.2",
        "type":"filebeat",
        "ephemeral_id":"3969b5f3-9aa2-4c5a-b8bd-971017f480c5",
        "hostname":"eeexx-asdddd",
        "id":"10b92cfc-b641-4dde-a72f-a599e178e05d"
    },
    "log":{
        "offset":48845307,
        "file":{"path":"/Log-xxxx.log"}
    },
    "message":"2019-11-19 14:42:33.830 INFO  .0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" """"",
    "input":{"type":"log"},
    "fields":{"log_topic":"xxx-click"},
    "ecs":{"version":"1.1.0"}
}
  • 根据你所需要的配置codec.format
output.kafka:
  codec.format: '%{[fields.log_topic]} %{[agent.hostname]}'

正文完
 0