Kibana – 使用坐标图

Kibana – 使用坐标图


Kibana 中的坐标地图将向您显示地理区域并根据您指定的聚合用圆圈标记该区域。

为坐标图创建索引

用于坐标图的 Bucket 聚合是 geohash 聚合。对于这种类型的聚合,您要使用的索引应该有一个 geo point 类型的字段。地理点是纬度和经度的组合。

我们将使用 Kibana 开发工具创建索引并向其添加批量数据。我们将添加映射并添加我们需要的 geo_point 类型。

我们将要使用的数据显示在此处 –

{"index":{"_id":1}}
{"location": "2.089330000000046,41.47367000000008", "city": "SantCugat"}
{"index":{"_id":2}}
{"location": "2.2947825000000677,41.601800991000076", "city": "Granollers"}
{"index":{"_id":3}}
{"location": "2.1105957495300474,41.5496295760424", "city": "Sabadell"}
{"index":{"_id":4}}
{"location": "2.132605678083895,41.5370461908878", "city": "Barbera"}
{"index":{"_id":5}}
{"location": "2.151270020052683,41.497779918345415", "city": "Cerdanyola"}
{"index":{"_id":6}}
{"location": "2.1364609496220606,41.371303520399344", "city": "Barcelona"}
{"index":{"_id":7}}
{"location": "2.0819450306711165,41.385491966414705", "city": "Sant Just Desvern"}
{"index":{"_id":8}}
{"location": "2.00532082278266,41.542294286427385", "city": "Rubi"}
{"index":{"_id":9}}
{"location": "1.9560805366930398,41.56142635214226", "city": "Viladecavalls"}
{"index":{"_id":10}}
{"location": "2.09205348251486,41.39327140161001", "city": "Esplugas de Llobregat"}

现在,在 Kibana Dev Tools 中运行以下命令,如下所示 –

PUT /cities
{
   "mappings": {
      "_doc": {
         "properties": {
            "location": {
               "type": "geo_point"
            }
         }
      }
   }
}

POST /cities/_city/_bulk?refresh
{"index":{"_id":1}}
{"location": "2.089330000000046,41.47367000000008", "city": "SantCugat"}
{"index":{"_id":2}}
{"location": "2.2947825000000677,41.601800991000076", "city": "Granollers"}
{"index":{"_id":3}}
{"location": "2.1105957495300474,41.5496295760424", "city": "Sabadell"}
{"index":{"_id":4}}
{"location": "2.132605678083895,41.5370461908878", "city": "Barbera"}
{"index":{"_id":5}}
{"location": "2.151270020052683,41.497779918345415", "city": "Cerdanyola"}
{"index":{"_id":6}}
{"location": "2.1364609496220606,41.371303520399344", "city": "Barcelona"}
{"index":{"_id":7}}
{"location": "2.0819450306711165,41.385491966414705", "city": "Sant Just Desvern"}
{"index":{"_id":8}}
{"location": "2.00532082278266,41.542294286427385", "city": "Rubi"}
{"index":{"_id":9}}
{"location": "1.9560805366930398,41.56142635214226", "city": "Viladecavalls"}
{"index":{"_id":10}}
{"location": "2.09205348251486,41.3s9327140161001", "city": "Esplugas de Llobregat"}

现在,在 Kibana 开发工具中运行上述命令 –

Kibana 开发工具

以上将创建 _doc 类型的索引名称城市,字段 location 是 geo_point 类型。

现在让我们向索引添加数据:城市 –

Kibana 索引名称

我们已经完成了使用数据创建索引名称引用的工作。现在让我们使用管理选项卡为城市创建索引模式。

Kibana 索引模式

此处显示了城市索引中字段的详细信息 –

Kibana 索引详情

我们可以看到 location 是 geo_point 类型。我们现在可以使用它来创建可视化。

坐标地图入门

转到可视化并选择坐标图。

坐标图

选择索引模式城市并配置聚合指标和存储桶,如下所示 –

配置聚合指标

如果单击“分析”按钮,您可以看到以下屏幕 –

分析按钮

根据经度和纬度,圆圈绘制在地图上,如上图所示。

觉得文章有用?

点个广告表达一下你的爱意吧 !😁