After NGINX access logs are collected and sent to Log Service, you can execute a query statement in Log Service to query the numbers of page views (PVs) per minute. You can add a filter of the Filter type to query the numbers of PVs for each request method by using dynamic list items. This topic describes how to add a filter of the Filter type to query the numbers of PVs for each request method based on NGINX access logs.

Prerequisites

Procedure

The following figure shows the operations that you need to perform to add a filter of the Filter type.

Add a filter of the Filter type

Step 1: Query and analyze data

To query the numbers of PVs per minute by using a query statement, perform the following operations:

  1. Log on to the Log Service console.
  2. In the Projects section, click the name of the project that you want to view.
  3. Choose Log Storage > Logstores. On the Logstores tab, click the Logstore that you want to view.
  4. Query and analyze data.
    1. Enter a query statement in the search box.

      In this example, enter the following query statement to query the numbers of PVs per minute:

      * | SELECT date_format(__time__ - __time__ % 60, '%H:%i:%s') as time, count(1) as count GROUP BY time ORDER BY time

      For more information about query and analysis, see Log search overview and Log analysis overview.

    2. Click 15 Minutes(Relative) to specify a time range for the query.
      You can select a relative time, select a time frame, or customize a time range.
      Note The query results may contain logs that are generated 1 minute earlier or later than the specified time range.
    3. Click Search & Analyze.

      The query results are displayed in a chart.

      visualization_best_practice_variable_query_result

Step 2: Add the chart to a dashboard

To add the chart that displays the numbers of PVs per minute to the NGINX Access Log dashboard, perform the following operations:

  1. On the Graph tab, click Add to New Dashboard.
  2. In the Add to New Dashboard dialog box, configure the parameters based on your business requirements and click OK.
    Dashboard
    For more information about the dashboard parameters, see Add a chart (Pro) to a dashboard or Add charts to a dashboard.

Step 3: Add a filter

To add a filter of the Filter type to query the numbers of PVs for a request method, perform the following operations:

  1. In the left-side navigation pane, click Dashboard.
  2. In the Dashboard list, click NGINX Access Log.

    The NGINX Access Log dashboard displays the numbers of PVs per minute.

    nginx access log dashboard cn
  3. In the upper-right corner of the NGINX Access Log page, click Edit. Then, click the Filter icon icon.
  4. In the Filter panel, configure the parameters and click OK.
    request method filter

    The following code provides an example of the query statement that uses dynamic list items:

    *|select distinct request_method

    For more information about filter parameters, see Add a filter.

  5. Adjust the filter layout of the page and click Save.
  6. In the Save message, click OK.

    The NGINX Access Log dashboard displays the request method filter.

    dashboard with filter

Step 4: Verify the results

In the Request Method Filter section of the NGINX Access Log page, set method to DELETE.

The following query statement is executed:
(*) and (request_method: DELETE) | SELECT date_format(__time__ - __time__ % 60, '%H:%i:%s') as time, count(1) as count GROUP BY time ORDER BY time 

The NGINX Access Log dashboard displays the numbers of PVs per minute for the DELETE method.

delete method