0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

intra-mart Accel Platformのログをlogstashで何とかしたい

Posted at

目的

  • 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/ はやっぱり便利。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?