【问题标题】:Working on JSON based logs using logstash使用 logstash 处理基于 JSON 的日志
【发布时间】:2015-07-23 18:31:23
【问题描述】:

我有一个日志,其中包含以下格式的日志

{ "start_time" : "12-May-2011", "name" : "this is first heading", "message" : "HELLO this is first message" }
{ "start_time" : "13-May-2011", "name" : "this is second heading", "message" : "HELLO this is second message" }
{ "start_time" : "14-May-2011", "name" : "this is third heading", "message" : "HELLO this is third message" }
...

我是 logstash 的新手,我目前有一个应用程序将这个日志条目创建为该文件中一个在另一个之下的 JSON 字符串(比如位置为 /root/applog/scheduler.log)

我正在寻找有关如何将此 json 从日志解析到不同字段到标准输出的帮助。 conf文件应该是怎样的。

注意:想法是稍后将其用于 kibana 进行可视化。

【问题讨论】:

    标签: json logstash


    【解决方案1】:

    示例配置:

    input {   
        file     {
            path => ["/root/applog/scheduler.log"]
            codec => "json"
            start_position => "beginning" # If your file already exists
        }
    }
    
    filter { } # Add filters here (optional)
    
    output {
        elasticsearch { } # pass the output to ES to prepare visualization with kibana
        stdout { codec => "rubydebug" } # If you want to see the result in stdout
    } 
    

    【讨论】:

      【解决方案2】:

      Logstash 包含一个 json codec,它将为您将 json 拆分为字段。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多