Using JSON with LogStash

后端 未结 3 1399
名媛妹妹
名媛妹妹 2020-12-05 02:26

I\'m going out of my mind here. I have an app that writes logs to a file. Each log entry is a JSON object. An example of my .json file looks like the following:



        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 02:53

    Try removing the json codec and adding a json filter

    input {
      file {
        type => "json"
        path => "/logs/mylogs.log"
      }
    }
    filter{
        json{
            source => "message"
        }
    }
    output {
      file {
        path => "/logs/out.log"
      }
    }
    

    you do not need the json codec because you do not want decode the source JSON but you want filter the input to get the JSON data in the @message field only.

    Hope this helps.

提交回复
热议问题