After NGINX access logs are collected and stored on Simple Log Service, you can use query and analysis statements to view the access volume for all request paths and visualize the access volume in a dashboard. If you want to track changes for different requests in the access volume, you can use the sparkline feature of the table.
Prerequisites
NGINX access logs are collected. For more information, see Collect text logs from servers.
Indexes are created. For more information, see Create indexes.
Step 1: Query and analyze data
Log on to the Simple Log Service console. In the Projects section, click the project you want.
In the left-side navigation pane, click Log Storage. In the Logstores list, click the logstore you want.
Enter the query and analysis statement, and then click Last 15 Minutes to set the time range for your query and analysis.
For example, you can use the following statement to query the sources of requests by HTTP referer, and aggregate the corresponding body byte sizes:
* | SELECT http_referer, array_agg(body_bytes_sent) as body_bytes_sent from log GROUP BY http_referer
For more information about array_agg, see array_agg function.
Step 2: Add a table
In the left-side navigation pane, choose Dashboard > Dashboards. In the dashboard list, click the dashboard you want. In the upper-right corner of the dashboard page, click Edit. In edit mode, click Add > Add Chart.
On the General Configurations tab, click the Table Pro icon in the Chart Types section. On the Search & Analysis tab, select Logstore (SQL) and choose the logstore you want, and enter the query statement. Select a time range, such as Last 15 Minutes, and click OK.
Step 3: Add a sparkline
Add a line chart
On the Field Configuration tab, click Add Field, and then select the column name from the drop-down list.
Click Add Configuration, select Field/Column Settings > Cell Display Mode, and select Line Chart.
The settings and results are shown in the figure below.
Add an area chart
On the Field Configuration tab, click Add Field, and then select the column name from the drop-down list.
Click Add Configuration, select Field/Column Settings > Cell Display Mode, and select Area Chart.
The settings and results are shown in the figure below.
Add a column chart
On the Field Configuration tab, click Add Field, and then select the column name from the drop-down list.
Click Add Configuration, select Field/Column Settings > Cell Display Mode, and select Column Chart.
The settings and results are shown in the figure below.