目的
- intra-mart Accel Platformのログをlogstashを使ってelasticsearchに入れて遊びたい
で、以下その履歴です。
requestログ編
リクエストログは、デフォルトでは、C:/%resin%/webapps/imart/WEB-INF/log/platform/request*.log に出力される。
以下、C:\resinにresinを入れたとする。
ログの書式については、デフォルト値のままとしたいので、こんな感じで定義されているとする。
[d{yyyy-MM-dd HH:mm:ss.SSS}] [thread] X{log.report.sequence} -5level logger{255} X{tenant.id} X{log.id} - X{client.session.id} X{request.remote.host} X{request.method} X{request.url} X{request.query_string} X{request.url.referer} X{request.page.time} X{request.accept.time} X{request.id}nopexn<
で、実際のlogstashの設定ファイル例
# 入力ファイルの設定
input {
file {
type => "resinlog"
path => "C:/resin/webapps/imart/WEB-INF/log/platform/request*.log"
tags => "request_log"
}
}
filter {
#resinのRequestログ用の処理
grok {
match => ["message", "\[%{TIMESTAMP_ISO8601:log_timestamp}\] \[%{DATA:resin_thread}\] %{NUMBER:sequence} %{LOGLEVEL:log_level}[\s]* %{NOTSPACE:logger} %{WORD:tenant_id} %{NOTSPACE:log_id} - %{NOTSPACE:session_id} %{IPORHOST:remote_host} %{WORD:request_method} %{URI:request_url} %{NOTSPACE:query_string} %{DATA:url_referer} %{NUMBER:page_time} %{TIMESTAMP_ISO8601:accept_time} %{NOTSPACE:request_id}"]
}
}
output {
# よしなにどうぞ
}
アクセスログ編
同じようにして、アクセスログも取得します。
input {
file {
type => "resinlog"
path => "C:/resin/log/access.log*"
tags => "access_log"
}
}
filter {
grok {
match => ["message", "%{IPORHOST:remote_ip_address} %{NOTSPACE:request_header} %{NOTSPACE:remote_user} \[%{HTTPDATE:log_timestamp}\] \"%{DATA:request_url}\" %{NUMBER:status_code} %{NUMBER:content_length} \"%{DATA:referer}\" \"%{DATA:useragent}\""]
}
}
output {
# よしなにどうぞ
}
個人メモ
http://grokdebug.herokuapp.com/ はやっぱり便利。