Kibana 使用区域地图
通过此可视化,您可以看到地理世界地图上表示的数据。在本章中,让我们详细了解这一点。
为区域地图创建索引
我们将创建一个新索引来处理区域地图可视化。我们要上传的数据显示在这里-
{"index":{"_id":1}}
{"country": "China", "population": "1313973713"}
{"index":{"_id":2}}
{"country": "India", "population": "1095351995"}
{"index":{"_id":3}}
{"country": "United States", "population": "298444215"}
{"index":{"_id":4}}
{"country": "Indonesia", "population": "245452739"}
{"index":{"_id":5}}
{"country": "Brazil", "population": "188078227"}
{"index":{"_id":6}}
{"country": "Pakistan", "population": "165803560"}
{"index":{"_id":7}}
{"country": "Bangladesh", "population": "147365352"}
{"index":{"_id":8}}
{"country": "Russia", "population": "142893540"}
{"index":{"_id":9}}
{"country": "Nigeria", "population": "131859731"}
{"index":{"_id":10}}
{"country": "Japan", "population": "127463611"}
请注意,我们将在开发工具中使用 _bulk upload 来上传数据。
现在,转到 Kibana Dev Tools 并执行以下查询-
PUT /allcountries
{
"mappings": {
"_doc": {
"properties": {
"country": {"type": "keyword"},
"population": {"type": "integer"}
}
}
}
}
POST /allcountries/_doc/_bulk?refresh
{"index":{"_id":1}}
{"country": "China", "population": "1313973713"}
{"index":{"_id":2}}
{"country": "India", "population": "1095351995"}
{"index":{"_id":3}}
{"country": "United States", "population": "298444215"}
{"index":{"_id":4}}
{"country": "Indonesia", "population": "245452739"}
{"index":{"_id":5}}
{"country": "Brazil", "population": "188078227"}
{"index":{"_id":6}}
{"country": "Pakistan", "population": "165803560"}
{"index":{"_id":7}}
{"country": "Bangladesh", "population": "147365352"}
{"index":{"_id":8}}
{"country": "Russia", "population": "142893540"}
{"index":{"_id":9}}
{"country": "Nigeria", "population": "131859731"}
{"index":{"_id":10}}
{"country": "Japan", "population": "127463611"}
接下来,让我们创建索引所有国家。我们已将国家/地区字段类型指定为
keyword-
PUT /allcountries
{
"mappings": {
"_doc": {
"properties": {
"country": {"type": "keyword"},
"population": {"type": "integer"}
}
}
}
}
注意-要使用区域地图,我们需要将要与聚合一起使用的字段类型指定为关键字类型。
完成后,使用 _bulk 命令上传数据。
我们现在将创建索引模式。转到 Kibana 管理选项卡并选择创建索引模式。
以下是所有国家/地区索引中显示的字段。
区域地图使用入门
我们现在将使用区域地图创建可视化。转到可视化并选择区域地图。
完成后选择索引为
所有国家并继续。
选择 Aggregation Metrics 和 Bucket Metrics,如下所示-
这里我们选择字段作为国家,因为我想在世界地图上显示相同的内容。
区域地图的矢量地图和连接字段
对于区域地图,我们还需要选择选项选项卡,如下所示-
选项选项卡具有在世界地图上绘制数据所需的图层设置配置。
矢量地图具有以下选项-
这里我们将选择世界国家,因为我有国家数据。
加入字段具有以下详细信息-
在我们的索引中,我们有国家/地区名称,因此我们将选择国家/地区名称。
在样式设置中,您可以选择要为国家/地区显示的颜色-
我们将选择 Reds。我们不会触及其余的细节。
现在,单击"分析"按钮以查看绘制在世界地图上的国家的详细信息,如下所示-
自托管矢量地图和 Kibana 中的联接字段
您还可以为矢量地图和连接字段添加您自己的 Kibana 设置。为此,请从 kibana 配置文件夹转到 kibana.yml 并添加以下详细信息-
regionmap:
includeElasticMapsService: false
layers:
-name: "Countries Data"
url: "http://localhost/kibana/worldcountries.geojson"
attribution: "INRAP"
fields:
-name: "Country"
description: "country names"
选项选项卡中的矢量地图将填充上述数据而不是默认数据。请注意,给定的 URL 必须启用 CORS,以便 Kibana 可以下载相同的 URL。使用的 json 文件应该是坐标连续的方式。例如-
https://vector.maps.elastic.co/blob/5659313586569216?elastic_tile_service_tos=同意
区域地图矢量地图详细信息自托管时的选项选项卡如下所示-
