ES クラスターと Logstash をインストールしました。私は多くの入力タイプのメッセージを持っています。今のところ、Gelf 入力タイプに問題があります。すべてのフィールドを文字列として ES に格納する必要がありますが、gelf の「メッセージ」フィールド内に json がある場合、ES はこの json から新しいマッピングを作成します。私はそれを望んでおらず、「メッセージ」フィールドの動的マッピングを無効にするために多くのバリアントを試しました。Logstash テンプレートの構成:
{
"mappings":{
"_default_":{
"_all":{
"enabled":false
},
"_source":{
"enabled":true,
"compress":true
},
"dynamic_templates":[
{
"message_template":{
"mapping":{
"index":"not_analyzed",
"type":"string"
},
"match":"message",
"match_mapping_type":"string"
},
"string_template":{
"mapping":{
"index":"not_analyzed",
"type":"string"
},
"match":"*",
"match_mapping_type":"string"
}
}
],
"properties":{
"@version":{
"index":"not_analyzed",
"type":"long"
},
"@timestamp":{
"type":"date",
"format":"dateOptionalTime"
},
"message":{
"type":"string",
"index":"not_analyzed",
"dynamic":false
}
}
}
},
"settings":{
"index.translog.flush_threshold_ops":50000,
"index.translog.flush_threshold_size":1073741824,
"refresh_interval":30,
"number_of_replicas":0,
"number_of_shards":1
},
"template":"gelf-*"
}
そしてlogstash出力:
output {
if [type] == "gelf" {
elasticsearch {
index => 'logstash-%{+YYYY.MM.dd}'
protocol => http
template_name => 'logstash-*'
workers => 4
template_overwrite => true
template => '/etc/logstash/index-template.json'
}
} else {
elasticsearch {
index => 'logstash-%{+YYYY.MM.dd}'
protocol => http
template_name => 'gelf-*'
workers => 4
template_overwrite => true
template => '/etc/logstash/gelf-template.json'
}
}
}
「メッセージ」フィールド内に json を含む新しいメッセージを受信すると、ES にマッピングされます: http://pastebin.com/R9Ei3zEK