All Products
Search
Document Center

Simple Log Service:Analyze website logs

Last Updated:Aug 02, 2023

Simple Log Service allows you to analyze logs by using the query statements that follow the SQL-92 syntax and visualize the analysis results in various charts. This topic describes how to analyze website logs in the Simple Log Service console and visualize the analysis results in charts.

Prerequisites

Background information

Website logs record important statistical information that facilitates website operations and maintenance, such as page views (PVs), unique visitors (UVs), distribution of accessed regions, and top 10 most visited pages. Simple Log Service provides various log collection methods and the log analysis feature. You can analyze logs in real time by using the query statements that follow the SQL-92 syntax and visualize the analysis results in charts. You can also create dashboards in Simple Log Service, DataV, Grafana, Tableau over Java Database Connectivity (JDBC), and Quick BI. Architecture

Procedure

  1. Log on to the Log Service console.
  2. In the Projects section, click the project that you want to manage.
  3. On the Log Storage > Logstores tab, click the Logstore that you want to manage.
  4. Enter a query statement in the search box, and specify a query time range.

    A query statement consists of a search statement and an analytic statement in the Search statement|Analytic statement format. For more information, see Search syntax and SQL syntax and functions.

    • Use a table to visualize client access within the previous day and sort the analysis results in descending order.

      * | SELECT remote_addr, count(*) as count GROUP BY remote_addr ORDER BY count DESC
      Table
    • Use a line chart to visualize the trends of the PVs, UVs, and average response time within the previous 15 minutes.

      * | select date_format(from_unixtime(__time__ - __time__% 60), '%H:%i:%S') as minutes, approx_distinct(remote_addr) as uv, count(1) as pv, avg(request_time) as avg group by minutes order by minutes asc limit 100000

      In the Configure Query and Analysis section, specify minutes for Axis X Field and specify pv, uv, and avg for Axis Y Field. The following figure shows the line chart. Line chart

    • Use a column chart to visualize the numbers of visits from different source addresses within the previous 15 minutes.

      * | select referer, count(1) as count group by referer
      Column chart
    • Use a bar chart to visualize the top 10 most visited pages within the previous 15 minutes.

      * | select  request_uri, count(1) as count group by request_uri order by count desc limit 10    
      Bar chart
    • Use a pie chart to visualize the PVs within the previous 15 minutes.

      * | select request_uri as uri , count(1) as c group by uri limit 10
      Pie chart
    • Use a single value chart to visualize the PVs within the previous 15 minutes.

      * | select count(1) as PV
      Single value chart
    • Use an area chart to visualize the visits from an IP address within the previous day.

      remote_addr: 10.0.XX.XX | select date_format(date_trunc('hour', __time__), '%m-%d %H:%i') as time, count(1) as PV group by time order by time limit 1000

      Specify time for X Axis and specify PV for Y Axis. The following figure shows the area chart.

      Area chart
    • Use a flow chart to visualize the trends of the number of requests by request method within the previous 15 minutes.

      * | select date_format(from_unixtime(__time__ - __time__% 60), '%H:%i:%S') as minute, count(1) as c, request_method group by minute, request_method order by minute asc limit 100000

      Specify minute for X Axis, specify c for Y Axis, and specify request_method for Aggregate Column. The following figure shows the flow chart.

      Flow chart
  5. Add a chart to a dashboard.

    Click Add to New Dashboard to add a chart to a dashboard. For more information, see Add a chart to a dashboard.