解决 kibana 中地图显示问题

解决 kibana 中地图显示问题

报错内容:

1
index pattern does not contain any of the following field types: geo_point

在使用 Kibana 生成地图相关视图的时候,发现上面 geoip 生成的数据类型不是 geo_point,而是:

1
2
3
4
5
6
7
8
9
10
11
GET ga_zt2m_180522-15/_mapping

"location": {
"properties": {
"lat": {
"type": "float"
},
"lon": {
"type": "float"
}
}

解决方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
PUT _template/ga
{
"index_patterns": "ga*",
"mappings": {
"doc": {
"dynamic": "true",
"properties": {
"geoip": {
"dynamic": true,
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
}
}

查看:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"ga": {
"order": 0,
"index_patterns": [
"ga*"
],
"settings": {},
"mappings": {
"doc": {
"dynamic": "true",
"properties": {
"geoip": {
"dynamic": true,
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
},
"aliases": {}
}
}

但是已经存在的 index 的 _mapping 并不能改变,我们可以将 index 删除然后重新将日志导入,但更快的方式是使用 _reindex:

1
2
3
4
5
6
7
8
9
10
11
12
13
POST _reindex

{
"source": {
"index": "ga_zt2m_180522-15"
},
"dest": {
"index": "ga_zt2m_180522-15-new"
}
}

# 删除旧的
DELETE ga_zt2m_180522-15

创建地图

file

坚持原创技术分享,您的支持将鼓励我继续创作!