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 如下图:
在这里,我们选择了字段作为国家,因为我想在世界地图上显示相同的内容。
区域地图的矢量地图和连接字段
对于区域地图,我们还需要选择选项选项卡,如下所示:
选项选项卡具有在世界地图上绘制数据所需的图层设置配置。
矢量图有以下选项:
在这里,我们将选择世界国家,因为我有国家数据。
Join 字段有以下详细信息:
在我们的索引中,我们有国家名称,因此我们将选择国家名称。
在样式设置中,你可以选择要为国家/地区显示的颜色:
我们将选择红队。我们不会触及其余的细节。
现在,点击分析按钮,可以看到世界地图上绘制的国家的详细信息,如下图所示:
Kibana 中的自托管向量映射和连接字段
你还可以为矢量地图和连接字段添加自己的 Kibana 设置。为此,请从 kibana config 文件夹中转到 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=agreeregion-map 矢量地图详情自托管时的选项选项卡如下所示: