読者です 読者をやめる 読者になる 読者になる

AKAI TSUKI

System development or Technical something

Configuration Logstash(output:stdout) 2

akai-tsuki.hatenablog.com の続きです。

設定を変更

line から json へ変更。

# vi /etc/logstash/conf.d/nginx-access_log.conf
# cat /etc/logstash/conf.d/nginx-access_log.conf
input {
  file {
    path => "/var/log/nginx/access.log"
  }
}

output {
  stdout {
    codec => "json"
  }
}
#

Logstashの出力

同じようにabコマンドでアクセスします。

# bin/logstash -f /etc/logstash/conf.d/nginx-access_log.conf
Settings: Default pipeline workers: 1
Pipeline main started
{"message":"127.0.0.1 - - [01/Jul/2016:07:36:44 +0000] \"GET / HTTP/1.0\" 200 612 \"-\" \"ApacheBench/2.3\" \"-\"","@version":"1","@timestamp":"2016-07-01T07:36:45.023Z","path":"/var/log/nginx/access.log","host":"e0b8c7a1e2cb"}

見やすく

{
  "message":"127.0.0.1 - - [01/Jul/2016:07:36:44 +0000] \"GET / HTTP/1.0\" 200 612 \"-\" \"ApacheBench/2.3\" \"-\"",
  "@version":"1",
  "@timestamp":"2016-07-01T07:36:45.023Z",
  "path":"/var/log/nginx/access.log",
  "host":"e0b8c7a1e2cb"
}