All Products
Search
Document Center

Simple Log Service:Add a filter of the filter type

Last Updated:Nov 03, 2025

After you collect NGINX access logs in Simple Log Service (SLS), you can use query and analytic statements to count the number of logs for different status codes and request methods. This topic uses NGINX access logs as an example to describe how to add a filter.

Prerequisites

Use case 1: Filter logs with a status code of 200

To filter for logs with a status code of 200, the query is transformed into the analytic statement status: 200 AND [search query] | [sql query] based on the filter configuration. In this case, the key is status and the value is 200. The following steps describe the configuration.

  1. In the edit mode of the dashboard, click the Filter 仪表盘过滤器-过滤器图标 icon in the upper-right corner.

  2. In the Filter panel, configure the following settings and click OK.

    image

  3. The configured filter is shown in the following figure.

    image

  4. The following is the raw data.

    Analytic statement:

     * | select status, count(*) as c group by status

    The following table lists the count for each status:

    image

  5. In the filter settings, set status to 200 to filter out data with any other status.

    image

    The analytic statement for the chart is:

    (*)and (status: 200)| select status, count(*) as c group by status 

Use case 2: Filter out logs that are not accessed using the GET or POST method from NGINX access logs

To exclude logs that use the GET or POST method, the query is transformed into the analytic statement NOT (request_method: GET OR request_method: POST) AND [search query] | [sql query] based on the filter configuration. The key is request_method, and the values are GET and POST. The following steps describe the configuration.

  1. In the edit mode of the dashboard, click the Filter 仪表盘过滤器-过滤器图标 icon in the upper-right corner.

  2. In the Filter panel, configure the following settings and click OK.

    image

  3. The configured filter is shown in the following figure.

    image

  4. The following is the original query data.

    Analytic statement:

    * | select request_method, count(*) as c group by request_method

    The following table shows the count of different request_method values.

    image

  5. In the filter settings, select POST and GET for request_method. This displays only logs with a request method of POST or GET.

    image

    The analytic statement for the chart is:

    (*)not (request_method: POST OR request_method: GET) | select request_method, count(*) as c group by request_method