我正在尝试在 Kibana 4.0.1 中实现瓦片地图可视化。
我可以geoip.location
在 Discover 部分看到数据,但是当我去 Visualize it as a Tile Map 时,我选择Geo Coordinates
bucket type ,然后是 aggregation type GeoHash
,然后当我去的时候Field
它是空白的。
- Kibana 4.0.1
- Logstash 1.4.2-1-2c0f5a1
- 弹性搜索 1.4.4
- 在 Debian 7 64 位上运行
这是我的logstash配置:
input {
udp {
port => 5514
type => cisco
}
}
filter {
grok {
match => { "message" => "\<%{NUMBER:num}\>%{NUMBER:seq}: \*%{SYSLOGTIMESTAMP:date}: \%SEC-6-IPACCESSLOGP: list Internet\-In\-%{WORD:acl_ver} denied %{WORD:protocol} %{IP:src}\(%{NUMBER:sport}\) \-\> %{IP:dest}\(%{NUMBER:dport}\), %{INT:hitcnt}" }
add_tag => ["grok_match", "cisco_acl_message"]
remove_field => [ "message" ]
}
geoip {
source => "src"
target => "geoip"
add_tag => ["geoip"]
database => "/etc/logstash/GeoLiteCity.dat"
}
}
output {
elasticsearch {
host => localhost
index => [ "firewall-%{+YYYY.MM.DD}" ]
}
}
这是一个日志记录的例子:
{
"_index": "firewall-2015.04.105",
"_type": "cisco",
"_id": "dJhGF6RtQuGXtlBTRCu2mQ",
"_score": null,
"_source": {
"@version": "1",
"@timestamp": "2015-04-15T21:06:08.357Z",
"type": "cisco",
"host": "172.17.10.1",
"num": "190",
"seq": "1872",
"date": "Apr 15 21:08:05.878",
"acl_ver": "20150223",
"protocol": "tcp",
"src": "94.102.51.96",
"sport": "26820",
"dest": "12.34.56.78",
"dport": "5900",
"hitcnt": "1",
"tags": [
"grok_match",
"cisco_acl_message",
"geoip",
"_grokparsefailure",
"geoip"
],
"geoip": {
"ip": "94.102.51.96",
"country_code2": "NL",
"country_code3": "NLD",
"country_name": "Netherlands",
"continent_code": "EU",
"region_name": "07",
"city_name": "Amsterdam",
"postal_code": "1000",
"latitude": 52.349999999999994,
"longitude": 4.916699999999992,
"timezone": "Europe/Amsterdam",
"real_region_name": "Noord-Holland",
"location": [
4.916699999999992,
52.349999999999994
],
"coordinates": [
4.916699999999992,
52.349999999999994
]
}
},
"fields": {
"@timestamp": [
1429131968357
]
},
"sort": [
1429131968357
]
}
有什么我想念的想法吗?
回答
在 Alain 为我指出正确的方向后,我开始研究字段映射。这是我的做法:
首先我检查了geoip
字段类型(我的索引被称为firewall*
)
curl http://localhost:9200/firewall*/_mapping/cisco/field/geoip.location?pretty
这回来了:
{
"firewall-2015.04.107" : {
"mappings" : {
"cisco" : {
"geoip.location" : {
"full_name" : "geoip.location",
"mapping":{"location":{"type":"float"}}
}
}
}
}
}
float
类型位置是我无法添加瓦片地图可视化的原因。我需要将其更改为geo_point
.
经过大量挖掘后,我找到了一种将location
类型映射更改geo_point
为使用输出模板的方法。我elasticsearch_templte.json
从
/opt/logstash/lib/logstash/outputs/elasticsearch/elasticsearch-template.json
到
/etc/logstash/templates/elasticsearch-firewall.json
编辑它并将模板从更改logstash*
为firewall*
(或任何您的索引名称模式)
"template" : "firewall*"
,
编辑 logstash 配置文件并将输出更改为:
output {
elasticsearch {
host => localhost
index => [ "firewall-%{+YYYY.MM.DD}" ]
template => "/etc/logstash/templates/elasticsearch-firewall.json"
template_name => "firewall"
}
}
删除firewall*
索引。
警告:这将删除您现有的所有可搜索数据!如果此数据很重要,您需要找到一种方法来动态更改字段类型而不删除索引。我在谷歌搜索中看到过这个,所以我知道这是可能的。
curl -XDELETE http://localhost:9200/firewall*
之后我重新启动了logstash和elasticsearch。
一旦我再次开始接收日志,我再次检查了映射
curl http://localhost:9200/firewall*/_mapping/cisco/field/geoip.location?pretty
{
"firewall-2015.04.107" : {
"mappings" : {
"cisco" : {
"geoip.location" : {
"full_name" : "geoip.location",
"mapping":{"location":{"type":"geo_point"}}
}
}
}
}
}
看看现在的位置类型如何geo_point
:-)
现在我可以添加一个 Tile Map 可视化。