I am creating an application where I need to put previous and after n number of lines in elasticsearch with current log. This is my current logstash configuraion.
What changes I need to make so that I can retrieve last n number of lines(Let's say 5) in my output?
input{ file{ path => "D:\ELK_Info\TestLogs_Updated.log"
#start_position => beginning
ignore_older => 0
sincedb_path => "NUL"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601}"
negate => true
what => "previous"
} } }
filter{
grok{
match => {
"message" => "%{TIMESTAMP_ISO8601:log_timestamp} %{DATA:line_number} %{DATA:log_level} %{DATA:log_type} %{NOTSPACE:space} %{GREEDYDATA:stackTrace}" } } mutate { remove_field => [ "tags", "space", "line_number"]} }
output { file{ path => "D:\ELK_Info\logstashOutput.log" }