10
12

More than 5 years have passed since last update.

fluentd+Elasticsearch+kibanaにApacheアクセスログを流した際の分かち書き対処

Last updated at Posted at 2014-12-04

現象

fluentdを使ってApacheアクセスログをElasticsearch+kibanaへ流した際に
"host"や"path"、"agent"などの値が分かち書きされてしまう。
(Elasticsearchが全文検索をデフォルトとしているため、"/"などを区切り文字として分割してしまう)

対処

これを解決するにはElasticsearchのMapping設定をすればよい。
fluentdが以下設定だとしたら

<match **>
  type elasticsearch
  type_name apache_access
  logstash_prefix apache_access
  ...
</match>

以下を実行して設定。
propertiesにどのキーを指定するかはお好みで。

curl -XPUT localhost:9200/_template/template_1 -d '
{
   "template" : "apache_access-*",
   "mappings" : {
       "apache_access": {
           "properties": {
                "host" : { "type" : "string", "index" : "not_analyzed" },
                "path" : { "type" : "string", "index" : "not_analyzed" },
                "referer" : { "type" : "string", "index" : "not_analyzed" },
                "domain" : { "type" : "string", "index" : "not_analyzed" },
                "agent" : { "type" : "string", "index" : "not_analyzed" }
           }
       }
   }
}
'
10
12
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
10
12