当前位置:网站首页>Solution to the problem that kibana's map cannot render longitude and latitude coordinate data

Solution to the problem that kibana's map cannot render longitude and latitude coordinate data

2022-06-24 16:46:00 An empty box

Recently, some customers have reported that kibana Of Maps The function cannot display longitude and latitude coordinate data .

Investigation thought :

Index based on customer configuration , stay Maps To configure the map , After configuring the view , An error is reported when an exception is found

Exception error display get geo_point The type field “geoip_location” Field . The preliminary inference is that the field types do not match, so the map cannot be rendered according to the declaration as geo_point The type field is used to render the longitude and latitude coordinates .

Check the customer side index field configuration :

In the template, the customer side is configured with the corresponding location The field is declared as geo_point type ( This is the right step )

In the specific field, the customer is responsible for location The field has been specified again

Specify both longitude and latitude as float type .

Citing official documents for the explanation of longitude and latitude coordinates :

https://www.elastic.co/guide/cn/elasticsearch/guide/current/lat-lon-formats.html

location The field is declared as geo_point after , We can index documents that contain longitude and latitude information . The longitude and latitude information can be in the form of string 、 Array or object ;

Official documents about location The fields are configured as follows :

PUT /attractions
{
  "mappings": {
      "properties": {
        "name": {
          "type": "keyword"
        },
        "location": {
          "type": "geo_point"
        }
      }
  }
}

Set the field type directly to geo_point type .

Based on the official website description There are three different ways to process data put;

PUT /attractions/_doc/1?pretty {"name":"Chipotle Mexican Grill","location":"40.715, -74.011"}   
PUT /attractions/_doc/2?pretty {"name":"Pala Pizza","location":{"lat":40.722,"lon":-73.989}}   
PUT /attractions/_doc/3?pretty {"name":"Mini Munchies Pizza","location":[-73.983,40.719]}

Then the map creation test ; It can render longitude and latitude .

Then based on the customer side index Adjust the field ( Keep only key fields , Other fields are omitted )

PUT /test-ip-map
{
    "aliases" : { },
    "mappings" : {
      "dynamic_templates" : [
        {
          "geoip.location" : {
            "match" : "geoip.location",
            "mapping" : {
              "type" : "geo_point"
            }
          }
        }
        }
      ],
      "properties" : {
        "geoip" : {
          "properties" : {
            "location" : {
              "type" : "geo_point"
            }
            
        }
      }
    }

}

Then the longitude and latitude data of the customer index reindex After entering the new index

location The fields are automatically resolved to longitude and latitude

Then the map is created and tested

Cause analysis :

Because the customer index is location Field specifically specifies float type , Although in the template geo_point Statement of , But the data is written to the index ,Maps Not able to correctly identify . So in the latitude and longitude field, you can directly use geo_point The type is enough .

To configure a map

1. Create contains location Index of field ; And write the data correctly .

2. Index based on longitude and latitude data to be displayed , stay index pattern Create the corresponding view in .

3. stay Kibana Maps in create new map ;

4. Click on add layer, Add a data source to your map ;

5. choice Documents, Add data sources ;

6. Select the view that has been created before

7. then Maps Automatically according to the configured view , To scan the index for location Field , At the same time, you can set different result set return options .

8. And then click add layer; Add map name , Set relevant layer parameters ( If you use the default, you do not need to change the layer parameters ); Click save , The longitude and latitude coordinates of the index contained in the corresponding view can be rendered in the map ;

Maps The principle and of loading data discover The functions are similar .

After the map takes effect , You can add... In the search box at the top filter, Or write KQL sentence , Filter and query data

Kibana Maps Link to the official documentation of the function ; At present, only 6.8 Version reference ;7.x The version has not been updated yet

https://www.elastic.co/guide/en/kibana/6.8/maps-getting-started.html

原网站

版权声明
本文为[An empty box]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/04/20210407135306100f.html