我已经编写了一个用于读取日志的logstash conf文件。如果我使用默认索引,即logstash- *,我可以在kibana中看到.raw字段。但是,如果我在
这样的logstash中的conf文件中创建一个新索引output{
elasticsearch {
hosts => "localhost"
index => "batchjob-*"}
}
然后新索引无法配置.raw字段。有没有解决方法可以解决它?非常感谢。
答案 0 :(得分:3)
原始字段由Logstash elasticsearch
输出在Elasticsearch中创建的specific index template创建。
您可以做的只是将该模板复制到名为batchjob.json
的文件,并将模板名称更改为batchjob-*
(见下文)
{
"template" : "batchjob-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true, "omit_norms" : true},
"dynamic_templates" : [ {
"message_field" : {
"match" : "message",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "analyzed", "omit_norms" : true,
"fielddata" : { "format" : "disabled" }
}
}
}, {
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "analyzed", "omit_norms" : true,
"fielddata" : { "format" : "disabled" },
"fields" : {
"raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
}
}
}
} ],
"properties" : {
"@timestamp": { "type": "date" },
"@version": { "type": "string", "index": "not_analyzed" },
"geoip" : {
"dynamic": true,
"properties" : {
"ip": { "type": "ip" },
"location" : { "type" : "geo_point" },
"latitude" : { "type" : "float" },
"longitude" : { "type" : "float" }
}
}
}
}
}
}
然后您可以像这样修改elasticsearch
输出:
output {
elasticsearch {
hosts => "localhost"
index => "batchjob-*"
template_name => "batchjob"
template => "/path/to/batchjob.json"
}
}