Count number of line in message field(multiline message field)


(Abinaya Gopinath) #1

Hi Team,

I am trying to do thread dumb analysis using logstash. I want to read number of line available in the message filed using logstash code and create a pie chart based on line count.

Please let me know how to count lines.

Thanks in Advance.


#2

Count the number of newlines and add 1. No fancy escaping schemes in logstash, just embed a literal newline in the string...

    ruby { code => 'event.set("numLines", 1 + event.get("message").count("
"))' }

(Abinaya Gopinath) #3

Thanks . It worked.