Codec multiline grok pattern for Logstash


so i am parsing multiline logs using Logstash. I need consider each log line will start with {"offset": currently it is printing into single line that's why it is coming in one message only

We are not using file beat hence need to implement in Logstash only

The multiline pattern is made in Logstash with sample logs:

input {
stdin {
        codec => multiline {
          pattern => "\{\"offset\""
          negate => true
          what => "previous"


	mutate {
		add_field => ["config_version", "v6.2"]

output {

Sample Logs:


Can you share an example of this multiline log? What you shared is a single json log line.

HI @leandrojmp ,
yes those logs are generating in singe line only in txt files. but they need each log should start with {"offset": and they don't want to use filebeat as well through logstash only

This is confusing, it is not clear what is the issue, if you have a single line with a json document you do not need multiline and you also not need grok.

Also, if you have log files you should use the file input, not stdin.

this one i used for testing purpose only but through file also not working

Can you share the multiline log you have?

What you shared is not a multiline log, is a json document, you do not need multiline nor grok to parse it.

A json codec would parse your log without any issues.

Json is now working here if my multiple logs in single line

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.