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

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]}'

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理