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
Website logs are collected. For more information, see Data collection overview.
Indexes are created. For more information, see Create indexes.
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.
Procedure
Log on to the Simple Log Service console.
In the Projects section, click the project that you want to manage.
In the left-side navigation pane, click Log Storage. In the Logstores list, click the Logstore that you want to manage.
Enter a query statement in the search box and click Last 15 Minutes to specify a query time range.
For more information, see Step 1: Enter a query statement.
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
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.
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
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
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
Use a single value chart to visualize the PVs within the previous 15 minutes.
* | select count(1) as PV
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.
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.
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.