This topic describes how to configure a map to display query results. It also includes examples.

Background information

You can add color blocks and marks to a map to display geographic data. Log Service provides three types of maps: Map of China, World Map, and AMap. Among them, AMap offers the scatter chart and heat map. You can include specific functions in search and analytics statements to display analysis results on different maps.

The basic elements of a map are as follows:
  • Map canvas
  • Color block

Procedure

  1. Log on to the Log Service console.
  2. Click the target project in the Projects section.
  3. Choose Log Management > Logstores, click the management icon of the target Logstore, and then select Management icon > Search & Analysis.
  4. On the Search & Analysis page of a Logstore, enter a search and analytics statement in the search box, specify the time range, and then click Search & Analyze.
    • To display the query result in the Map of China, include the ip_to_province function in the statement.
    • To display the query result in the World Map, include the ip_to_country function in the statement.
    • To display the query result in the AMap, include the ip_to_geo function in the statement.

    The system automatically displays the Graph tab when the search and analytics statement is completed.

  5. Click Map - 001 to display the query results in a map.
    The Map of China Map - 001 is taken as an example to describe how to configure a map.
  6. On the Properties tab on the right, configure the properties of the map.
    Configuration item Background information
    Location information The location information recorded in logs. The item varies depending on the map type you select as follows:
    • Provinces (Map of China)
    • Country (World Map)
    • Longitude/Latitude (AMap)
    Value Column The data volume of the location information.

Example map of China

You can include the ip_to_province function in a statement to display query results in a map of China.
  • SQL statement
    * | select  ip_to_province(remote_addr) as address, count(1) as count group by address order by count desc limit 10
  • Dataset
    address count
    Guangdong 163
    Zhejiang 110
    Fujian 107
    Beijing 89
    Chongqing 28
    Heilongjiang 19

    Select address for Provinces and count for Value Column.

Map of China

Example world map

You can include the ip_to_country function in a statement to display query results in a world map.
  • SQL statement
    * | select  ip_to_country(remote_addr) as address, count(1) as count group by address order by count desc limit 10
  • Dataset
    address count
    China 8354
    United States 142

    Select address for Country and count for Value Column.

World Map

Example of Amap

You can include the ip_to_geo function in a statement to display query results in AMap. The address column in the dataset contains the latitude and longitude information, which are separated with a comma (,). If the longitude and latitude are indicated by two separate columns named lng and lat, you can use the concat('lat', ',', lng') function to integrate the two columns into one column.
  • SQL statement
    * | select  ip_to_geo(remote_addr) as address, count(1) as count group by address order by count desc limit 10
  • Dataset
    address count
    39.9289,116.388 771
    39.1422,117.177 724
    29.5628,106.553 651
    30.2936,120.161420 577
    26.0614,119.306 545
    34.2583,108.929 486

    Select address for Longitude/Latitude and count for Value Column.

The scatter chart is used by default. If data points are densely distributed on the map, you can convert it to the heat map.