我想在Kibana4的瓷砖 map 中显示geoip字段。
使用标准/自动logstash geoip映射进行elasticsearch,一切正常。
但是,当创建一个非标准的geoip字段时,我不太确定如何在logstash中自定义elasticsearch-template.json以便在elasticsearch中正确表示此字段,以便可以在Kibana4中选择该字段以用于 slice map 创建。
当然,自定义标准模板不是最好的方法-更好地创建一个自定义模板,并在logstash.conf的elasticsearch输出中指向它。我只是想快速检查一下如何定义映射,因此我修改了标准模板。
我的logstash.conf:
input {
tcp {
port => 514
type => syslog
}
udp {
port => 514
type => syslog
}
}
filter {
# Standard geoip field is automatically mapped by logstash to
# elastic search by using the elasticsearch-template.json file
geoip { source => "host" }
grok {
match => [
"message", "<%{POSINT:syslog_pri}>%{YEAR} %{SYSLOGTIMESTAMP:syslog_timestamp} %{DATA:device} <%{POSINT:status}> %{WORD:activity} %{DATA:inout} \(%{DATA:msg}\) Src:%{IPV4:src} SPort:%{INT:sport} Dst:%{IPV4:dst} DPort:%{INT:dport} IPP:%{INT:ipp} Rule:%{INT:rule} Interface:%{WORD:iface}",
"message", "<%{POSINT:syslog_pri}>%{YEAR} %{SYSLOGTIMESTAMP:syslog_timestamp} %{DATA:device} <%{POSINT:status}> %{WORD:activity} %{DATA:inout} \(%{DATA:msg}\) Src:%{IPV4:src} Dst:%{IPV4:dst} IPP:%{INT:ipp} Rule:%{INT:rule} Interface:%{WORD:iface}",
"message", "<%{POSINT:syslog_pri}>%{YEAR} %{SYSLOGTIMESTAMP:syslog_timestamp} %{DATA:device} <%{POSINT:status}> %{WORD:activity} %{DATA:inout} \(%{DATA:msg}\) Src:%{IPV4:src} Dst:%{IPV4:dst} Type:%{POSINT:type} Code:%{INT:code} IPP:%{INT:ipp} Rule:%{INT:rule} Interface:%{WORD:iface}"
]
}
# Is not mapped automatically by logstash in that it can be
# chosen in Kibana4 for tile map creation
geoip {
source => "src"
target => "src_geoip"
}
}
output {
elasticsearch {
host => "localhost"
protocol => "http"
}
}
我的... logstash-1.4.2 \ lib \ logstash \ outputs \ elasticsearch \ elasticsearch-template.json:
{
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true},
"dynamic_templates" : [ {
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "analyzed", "omit_norms" : true,
"fields" : {
"raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
}
}
}
} ],
"properties" : {
"@version": { "type": "string", "index": "not_analyzed" },
"geoip" : {
"type" : "object",
"dynamic": true,
"path": "full",
"properties" : {
"location" : { "type" : "geo_point" }
}
},
"src_geoip" : {
"type" : "object",
"dynamic": true,
"path": "full",
"properties" : {
"location" : { "type" : "geo_point" }
}
}
}
}
}
}
更新:我还没有弄清楚何时将此json文件应用于elasticsearch。我按照this question中列出的提示进行操作,并将json文件复制到elasticsearch目录中的config / templates文件夹中。删除indizes并重新启动elasticsearch之后,模板已成功应用。
无论如何,字段“src_geoip.location”仍然不会在Kibana4的 slice map 创建表单中显示(仅标准geoip.location字段会显示)。
最佳答案
编辑模板后尝试覆盖模板。更改配置后,在Kibana中重新创建索引。
output {
elasticsearch {
template_overwrite => "true"
...
}
}
关于elasticsearch - 如何使用elasticsearch在logstash中映射geoip字段,以便在Kibana4的平铺 map 中显示它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29237194/