How do I match a newline in grok/logstash?

后端 未结 3 1798
名媛妹妹
名媛妹妹 2020-12-24 06:34

I have a remote machine that combines multiline events and sends them across the lumberjack protocol.

What comes in is something that looks like this:



        
相关标签:
3条回答
  • 2020-12-24 06:52

    All GREEDYDATA is is .*, but . doesn't match newline, so you can replace %{GREEDYDATA:message} with (?<message>(.|\r|\n)*)and get it to be truly greedy.

    0 讨论(0)
  • 2020-12-24 06:56

    My final grok for Vertica log using (?m) and [^\n]+

    match => ["message","(?m)%{TIMESTAMP_ISO8601:ClientTimestamp}%{SPACE}(%{DATA:Action}:)?(%{DATA:ThreadID} )?(\[%{DATA:Module}\] )?(\<%{DATA:Level}\> )?(\[%{DATA:SubAction}\] )?(@%{DATA:Nodename}:)?( (?<Session>(\{.*?\} )?.*?/.*?): )?(?<message>[^\n]+)((\n)?(\t)?(?<StackTrace>[^\n]+))?"]
    

    Thanks to asperla

    https://github.com/elastic/logstash/issues/2282

    0 讨论(0)
  • 2020-12-24 07:14

    Adding the regex flag to the beginning allows for matching newlines:

    match => [ "message", "(?m)%{TIMESTA...
    
    0 讨论(0)
提交回复
热议问题