Kibana 简明教程

Kibana - Working With Coordinate Map

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

Coordinate maps in Kibana will show you the geographic area and mark the area with circles based on aggregation you specify.

Create Index for Coordinate Map

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

The Bucket aggregation used for coordinate map is geohash aggregation. For this type of aggregation, your index which you are going to use should have a field of type geo point. The geo point is combination of latitude and longitude.

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

We will create an index using Kibana dev tools and add bulk data to it. We will add mapping and add the geo_point type that we need.

我们要使用的数据如下所示 −

The data that we are going to use is shown here −

{"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 开发工具中运行以下命令,如下所示 −

Now, run the following commands in Kibana Dev Tools as shown below −

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 开发工具中运行以上命令 −

Now, run the above commands in Kibana dev tools −

kibana dev tools

上述将创建类型为 _doc 的索引名称城市,字段位置为类型 geo_point。

The above will create index name cities of type _doc and the field location is of type geo_point.

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

Now let’s add data to the index: cities −

kibana index name

我们已完成创建名称为 cities พร้อม数据的索引。现在,让我们使用管理选项卡为城市创建索引模式。

We are done creating index name cites with data. Now let us Create index pattern for cities using Management tab.

kibana index pattern

此处显示了 cities 索引中字段的详细信息 −

The details of fields inside cities index are shown here −

kibana index details

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

We can see that location is of type geo_point. We can now use it to create visualization.

Getting Started with Coordinate Maps

转至可视化并选择坐标地图。

Go to Visualization and select coordinate maps.

coordinate maps

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

Select the index pattern cities and configure the Aggregation metric and bucket as shown below −

configure aggregation metric

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

If you click on Analyze button, you can see the following screen −

analyze button

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

Based on the longitude and latitude, the circles are plotted on the map as shown above.