logstash 各种时间转换

日期格式转换:

/***** nginx 访问日志
[elk@zjtest7-frontend config]$ cat stdin02.conf 
input {
    stdin {
    }
}
filter {
    grok {
        match => ["message", "%{IPORHOST:clientip} \[%{HTTPDATE:time}\]"]
    }
    #date {
    #    match => ["time", "dd/MMM/yyyy:HH:mm:ss Z"]
    #}
}
output {
 stdout {
  codec=>rubydebug{}
   }
 }

[elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf 
Settings: Default pipeline workers: 1
Pipeline main started
 10.171.246.184 [22/Sep/2016:00:13:59 +0800] "GET /resources/css/base.css?06212016 HTTP/1.1" - 200 12638 "https://www.zjcap.cn/" 
{
       "message" => " 10.171.246.184 [22/Sep/2016:00:13:59 +0800] \"GET /resources/css/base.css?06212016 HTTP/1.1\" - 200 12638 \"https://www.zjcap.cn/\" ",
      "@version" => "1",
    "@timestamp" => "2016-09-22T00:54:17.154Z",
          "host" => "0.0.0.0",
      "clientip" => "10.171.246.184",
          "time" => "22/Sep/2016:00:13:59 +0800"
}


打开时间转换:
[elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf 
Settings: Default pipeline workers: 1
Pipeline main started
 10.171.246.184 [22/Sep/2016:00:13:59 +0800] "GET /resources/css/base.css?06212016 HTTP/1.1" - 200 12638 "https://www.zjcap.cn/" 
{
       "message" => " 10.171.246.184 [22/Sep/2016:00:13:59 +0800] \"GET /resources/css/base.css?06212016 HTTP/1.1\" - 200 12638 \"https://www.zjcap.cn/\" ",
      "@version" => "1",
    "@timestamp" => "2016-09-21T16:13:59.000Z",
          "host" => "0.0.0.0",
      "clientip" => "10.171.246.184",
          "time" => "22/Sep/2016:00:13:59 +0800"
}



/***** nginx 错误日志
[elk@zjtest7-frontend config]$ cat stdin02.conf 
input {
    stdin {
    }
}
filter {
    grok {
        match => ["message", "(?




你可能感兴趣的:(Logstash)