1

我使用 Logstash 来处理我的网络日志,但我发现数据丢失的问题。

现在我有 100 行日志。通过 Logstash 处理后,我得到的结果有时少于 100 行。奇怪的是它没有显示任何错误消息。

以下代码是我对 Logstash 的配置:

input {
    file {
        path => "/home/jhowliu/Work/Log/201506/testing.log"
        start_position => "beginning"
        sincedb_path => "/dev/null"
    }
}

filter {
    csv {
        columns => ["ip", "time", "request", "status", "refer", "browser"]
    }

    grok {
        match => {
            "time" => "%{MONTHDAY:day}/%{MONTH:month}/%{YEAR:year}:%{TIME:time}"
        }
        overwrite => ["time"]
    }

    mutate {
        replace => {"time" =>"%{day}-%{month}-%{year} %{time}" }
    }

    if [request] != "-" {
        grok {
            match => {
                "request" => "%{URIPATH:dest_path}"
            }
        }
    }

    if [refer] != "-" {
        grok {
            match => {
                "refer" => "%{URIHOST}%{URIPATH:source_path}"
            }
        }
    }
}

output { 
    csv {
        fields => ["time", "ip", "dest_path", "source_path", "status"]
        path => "/home/jhowliu/testing.log"
    }
}
4

0 回答 0