All Products
Search
Document Center

:日志查询

Last Updated:Apr 02, 2026

After you enable log collection for a Web Application Firewall (WAF) protected object, use log query to search and analyze log data, generate charts, and create alerts based on query results.

Prerequisites

Query and analyze logs

  1. Log on to the Web Application Firewall 3.0 console. From the top menu bar, select the resource group and region (Chinese Mainland or Outside Chinese Mainland) for the WAF instance.

  2. In the navigation pane on the left, choose Detection and Response > Log Service.
  3. On the Log Service page, select the protected object whose logs you want to query.

    Important

    The protected object must have log collection enabled (the Status toggle must be on). If it isn't enabled, WAF won't collect log data or provide log query and analysis. If log collection isn't enabled for the selected protected object, find it on this page, click the object name, and turn on the Status toggle. Alternatively, go to the Log Configuration page, click the Delivery Settings tab, and use Status of Delivery to Simple Log Service to manage log collection for all protected objects. For details, see Manage log delivery status.

    日志报表

  4. On the Log Query tab, use query and analytics statements to search and analyze WAF log data.

    日志查询与分析

    Follow these steps:

    1. In the statement input box (labeled ①), enter a query statement.

      Query statements use the Alibaba Cloud Log Service syntax. For details about this syntax, see Query syntax and functions. Use WAF log data fields as query fields. For a list of supported query fields, see Log fields.

      If you're unfamiliar with the log query syntax, use Advanced Search. Expand Advanced Search above the statement input box, configure your search conditions, and click Search. The statement input box automatically generates a query statement that matches your conditions.高级搜索 Advanced search supports the following search conditions:

      Search condition

      Description

      IP

      IP address of the client that sent the request.

      Request ID

      Unique ID that WAF generates for the client request. WAF includes this ID in block pages and CAPTCHA challenge responses, and you can use it for issue analysis and troubleshooting.

      Rule ID

      ID of the WAF protection rule that the request matched. Find the rule ID on the Protection Rules page, or get it from the rule-hit records and statistics on the Security Reports page. For more information, see Security reports.

      Status Code Returned from Origin Server

      HTTP status code that the origin server returned in response to WAF's back-to-origin request.

      Status Code Returned from WAF

      HTTP status code that WAF returned to the client.

      Protection Module

      Type of WAF protection module that the request matched. For an overview of WAF protection modules and how to configure protection rules for each module, see Protection configuration overview.

    2. To run statistical analysis on query results, append an analytics statement after the query statement in the statement input box (labeled ①). To retrieve only matching log data, skip this step.

      Separate the analytics statement from the query statement with a pipe character (|). Analytics statements use standard SQL 92 syntax. For details, see Overview of log query and analysis.

    3. Use the time range selector (labeled ②) to set the time range for the logs you want to query.

    4. Click Log Query(labeled ③).

      The query and analysis results — WAF log data that matches your query — appear at the bottom of the page. Results include a log distribution histogram, Original Request Header, charts, and log clustering. From the results, run quick analysis, generate charts, and set up alerts. For details, see Description of the Query/Analysis page.

Description of the Query/Analysis page

Page overviewimage

Histogram

image

  • Hover over a green block to view the time range and the number of log hits in that time range.

  • Double-click a green block to view the log distribution with a finer time granularity. The Raw Logs tab also displays the query results for the specified time range.

Raw Logs

  • Log detailsimage

    • Click Table or Raw to switch the log format.

    • 下载日志 > Download Log: Download the logs to your local computer. For more information, see Download logs.

    • image.png>JSON Settings: Set the JSON display type and expansion level.

    • image.png>Event Settings: Configure events for raw logs.

    • image.png: Copy the log content.

    • image.png: SLS Copilot. Summarize information and find error messages in the log content.

    • 查询日志-004: View the context of a specific log in the original file. The contextual query feature is available only for logs collected using Logtail. For more information, see Contextual query.

    • LiveTail: Monitor log content in real time and extract key log information. The LiveTail feature is available only for logs collected using Logtail. For more information, see LiveTail.

  • Displayed Fieldsimage

    • In the Displayed Fields section, click the image.png icon next to a field to remove it from Displayed Fields. The field is then hidden from the log information on the right.

    • image.png: Save a view. After you set the displayed fields, you can save the view. You can then select the saved view from the drop-down list above the log details.

    • image.png>Tag Settings: Set a field as a system tag.

    • image.png>Alias: After you enable this feature, field names are replaced by their aliases. Fields without an alias continue to show their original names. To set a field alias, see Create an index.

  • Indexed fieldsimage

    • In the Indexed Fields section, click the image.png icon next to a field to add it to Displayed Fields. The field is then shown in the log information on the right.

    • image.png: View the Basic Distribution and Statistical Metrics of the field. For more information, see Field settings.

Statistical charts

Statistical charts are rendered by Simple Log Service based on query and analysis statements. Simple Log Service provides various chart types, such as tables, line charts, and column charts. For more information, see Statistical charts. After you run a query and analysis statement, you can view the resulting visualizations on the Statistical Charts tab. image

Other features on this tab are described below:

  • Add to Dashboard: A dashboard is a real-time data analysis tool provided by Simple Log Service. Click Add to Dashboard to save the chart to a dashboard. For more information, see Visualization overview.

  • Save as Scheduled SQL: Simple Log Service provides the Scheduled SQL feature. This feature lets you periodically analyze data, store aggregated data, and perform projection and filtering. For more information, see Scheduled SQL.

  • Interaction Occurrences: Interaction occurrences are an essential data analytics feature. This feature lets you change the hierarchy of data dimensions and the granularity of analysis to obtain more detailed information from your data. For more information, see Add an interaction occurrence to a dashboard for drill-down analysis.

LogReduceimage

On the LogReduce tab, click Enable LogReduce to aggregate similar logs during log collection. For more information, see LogReduce.

SQL Enhancementimage

Click the SQL独享版 icon in the upper-right corner to enable Dedicated SQL for a single query. If the data volume is large, a standard SQL query may not be able to analyze all logs within the specified time range. Enabling Dedicated SQL adds computing resources to increase the amount of data that can be analyzed in a single query. To enable this feature by default, see High-performance and accurate query and analysis (Dedicated SQL).

Alertingimage

Click the 另存为告警 icon in the upper-right corner and Save as Alert. For more information, see Alert configuration quick start.

Saved searchimage

Click the 快速查询 icon in the upper-right corner and Save as Saved Search. You can use saved queries to quickly run query and analysis operations. For more information, see Saved search.

Sharingimage

Click the image.png icon in the upper-right corner to copy the link to the current page and share it with other users. For more information, see Embed console pages and share log data.