2016-10-08 15 views
0

私はelasticstarchでカスタムインデックスを作成するためにlogstashを使用する必要があります。私はelasticsearchで新しいテンプレートを作成しました.logstashの設定ではテンプレートパス、template_name、template_overwriteの値を指定しましたが、logstashを実行するたびに新しいインデックスがlogstash-dd-mm-yy regexで生成されます。 、 logstash -configファイルがlogstashでカスタムelasticsearchインデックスを作成

input { 
    file { 
    path => "/temp/file.txt" 
    type => "words" 
    start_position => "beginning"  
    } 
} 
filter { 

    mutate { 
    add_field => {"words" => "%{message}"} 
    } 

} 
output { 
    elasticsearch { 
    hosts => ["elasticserver:9200"] 
    template => "pathtotemplate.json" 
    template_name => "newIndexName-*" 
    template_overwrite => true 
    } 
    stdout{} 
} 

インデックステンプレートファイルが

{ 
    "template": "dictinary-*", 
    "settings" : { 
     "number_of_shards" : 1, 
     "number_of_replicas" : 0, 
     "index" : { 
      "query" : { "default_field" : "@words" }, 
      "store" : { "compress" : { "stored" : true, "tv": true } } 
     } 
    }, 
    "mappings": { 
     "_default_": { 
      "_all": { "enabled": false }, 
      "_source": { "compress": true }, 
      "dynamic_templates": [ 
       { 
        "string_template" : { 
         "match" : "*", 
         "mapping": { "type": "string", "index": "not_analyzed" }, 
         "match_mapping_type" : "string" 
        } 
       } 
      ], 
      "properties" : { 
       "@fields": { "type": "object", "dynamic": true, "path": "full" }, 
       "@words" : { "type" : "string", "index" : "analyzed" }, 
       "@source" : { "type" : "string", "index" : "not_analyzed" }, 
       "@source_host" : { "type" : "string", "index" : "not_analyzed" }, 
       "@source_path" : { "type" : "string", "index" : "not_analyzed" }, 
       "@tags": { "type": "string", "index" : "not_analyzed" }, 
       "@timestamp" : { "type" : "date", "index" : "not_analyzed" }, 
       "@type" : { "type" : "string", "index" : "not_analyzed" } 
      } 
     } 
    } 
} 

であるあなたがやりたい

答えて

2

を助けてください、あなたはを設定する必要がありますElasticsearch出力ブロックのパラメータ。出力ブロックは次のようになります。

output { 
    elasticsearch { 
    hosts => ["elasticserver:9200"] 
    index => "newIndexName-%{+YYYY.MM.dd}" 
    template => "pathtotemplate.json" 
    template_name => "newIndexName-*" 
    template_overwrite => true 
    } 
    stdout{} 
} 
関連する問題