如何使用logstash配置检索日志文件中n个前一行和后一行?

时间:2018-10-22 06:59:53

标签: elasticsearch logstash elastic-stack

我正在创建一个应用程序,该应用程序需要在带有当前日志的elasticsearch中放置前n行和后n行。这是我当前的logstash配置。 我需要进行哪些更改,以便可以在输出中检索最后n行(假设5行)?

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" }

0 个答案:

没有答案