All Products
Search
Document Center

Web Application Firewall:Query logs

Last Updated:Mar 31, 2026

Use Log Service to search and analyze the full request logs for your WAF-protected objects. From the query results, you can generate charts, set up alert rules, and save queries for reuse.

Log Service shows all collected request logs for a protected object. To view a summary of security events matched by WAF protection rules, go to Detection and Response > Security Reports instead.

Prerequisites

Before you begin, make sure that:

Query and analyze logs

  1. Log on to the WAF 3.0 console. In the top navigation bar, select the resource group and region of the WAF instance. Supported regions: Chinese Mainland and Outside Chinese Mainland.

  2. In the left-side navigation pane, choose Detection and Response > Log Service.

  3. At the top of the Log Service page, select the protected object whose logs you want to query.

    Important

    Make sure the Status switch is turned on for the selected protected object. If log delivery is disabled, WAF stops collecting logs for that object and no logs are available for query or analysis. To enable log delivery, search for the protected object on this page, click its name, and turn on the Status switch. Alternatively, go to Log Configuration > Delivery Settings and manage log delivery in the Status of Delivery to Simple Log Service column. For details, see Manage log delivery status.

    日志报表

  4. Enter a query statement and run it to search and analyze logs.

    1. In the search box (labeled 1 in the figure), enter a search statement. Write the search statement using Simple Log Service search syntax. Use WAF log fields as search fields where needed. For a list of supported log fields, see Log fields. If you're not familiar with the search syntax, click Advanced Search above the search box. Specify search conditions and click Search — the corresponding search statement is generated automatically. 高级搜索 The following search conditions are available:

      Search condition

      Description

      IP

      The IP address of the client that sent the request.

      Request ID

      The unique identifier WAF assigns to each client request. WAF includes the request ID on block pages and CAPTCHA challenge pages. Use the request ID to investigate and troubleshoot specific requests.

      Rule ID

      The ID of the WAF protection rule matched by the request. Find rule IDs on the Rule Configuration page, or retrieve them from rule match records on the Security Reports page. For details, see Security reports.

      Status Code Returned From Origin Server

      The HTTP status code the origin server returned in response to the request forwarded by WAF.

      Status Code Returned From WAF

      The HTTP status code WAF returned to the client.

      Protection Module

      The WAF protection module that matched the request. For details on protection modules and configuration, see Protection configuration overview.

    2. (Optional) To run calculations or statistical operations on the search results, append an analytic statement to the search statement using a vertical bar (|) as the separator. Write the analytic statement in standard SQL-92 syntax. For details, see Log analysis overview.

    3. Use the time picker (labeled 2 in the figure) to set the time range for the query.

    4. Click Search & Analyze (labeled 3 in the figure). The query results appear in the lower part of the page: a log distribution histogram at the top, followed by the Raw Logs, Graph, and LogReduce tabs.

    日志查询与分析

Explore query results

After running a query, use the results page to investigate logs, build charts, and set up alerts. The sections below describe the available tools.

Page overview

image

Histogram

image

The histogram shows log distribution over the queried time range. Each green rectangle represents a time interval.

  • Hover over a rectangle to see the time interval and the number of returned logs within it.

  • Double-click a rectangle to zoom into that time interval for a finer-grained view. The Raw Logs tab updates to show only logs within the selected interval.

Raw Logs

Log details

image
ActionDescription
Table / Raw DataSwitch between table view and raw log view.
![下载日志](https://help-static-aliyun-doc.aliyuncs.com/assets/img/en-US/0571777961/p103211.png) > Download LogDownload the current log results to your computer. For details, see Download logs.
![image.png](https://help-static-aliyun-doc.aliyuncs.com/assets/img/en-US/9930540071/p724474.png) > JSON ConfigurationsSet the display type and expansion level for JSON fields.
![image.png](https://help-static-aliyun-doc.aliyuncs.com/assets/img/en-US/9930540071/p724474.png) > Event SettingsConfigure events for raw logs. For details, see Event settings.
image.pngCopy the log content.
image.pngLabel specific information or query error information in the log. This icon also provides copilot assistance.
查询日志-004View context information for a specific log entry in the raw log file. Available only for logs collected by Logtail. For details, see Contextual query.
LiveTailMonitor log content in real time and extract key log information. Available only for logs collected by Logtail. For details, see LiveTail.

Displayed fields

image

Displayed fields appear in the log content panel on the right. Customize which fields are shown depending on the type of analysis you're performing — for example, focus on IP and rule ID when investigating potential attacks, or on status codes when troubleshooting origin errors.

ActionDescription
Hover over a field > click image.pngRemove the field from Displayed Fields. The field no longer appears in the log content panel.
image.pngSave the current field view to your favorites. Select saved views from the drop-down list above the field panel.
![image.png](https://help-static-aliyun-doc.aliyuncs.com/assets/img/en-US/9930540071/p724463.png) > Tag SettingsAdd fields as system tags.
![image.png](https://help-static-aliyun-doc.aliyuncs.com/assets/img/en-US/9930540071/p724463.png) > AliasReplace field names with aliases. Fields without an alias retain their original names. For details on setting aliases, see Create indexes.

Indexed fields

image
ActionDescription
Hover over a field > click image.pngAdd the field to Displayed Fields so it appears in the log content panel.
image.pngView field details, including Basic Distribution and Statistical Metrics. For details, see Field settings.

Graph

image

Simple Log Service renders the query results as charts — tables, line charts, column charts, and more. For a full list of chart types, see Charts.

Additional actions on the Graph tab:

ActionDescription
Add to New DashboardSave the current chart to a dashboard for ongoing monitoring. For details, see Overview of visualization.
Save as Scheduled SQL JobRun this analysis automatically on a schedule and aggregate or store the results. For details, see How Scheduled SQL works.
Interaction OccurrencesDrill down into specific data dimensions for more granular analysis. For details, see Configure an interaction occurrence for a dashboard to perform drill-down analysis.

LogReduce

image

Click Enable LogReduce to cluster similar logs during log collection. For details, see LogReduce.

SQL Enhancement

image

Click the SQL独享版 icon in the upper-right corner to enable Dedicated SQL. Standard SQL may not be able to process all data in a single query when the dataset is large or covers a long time range. Dedicated SQL increases the available computing resources and the amount of data that can be analyzed per query. For details, see Enable Dedicated SQL.

Alerting

image

Click the 另存为告警 icon in the upper-right corner to configure an alert rule based on the current query. For details, see Configure an alert rule in Simple Log Service.

Saved search

image

Click the 快速查询 icon in the upper-right corner to save the current query statement as a saved search for quick reuse. For details, see Saved search.

Sharing

image

Click the image.png icon in the upper-right corner to copy a shareable link to the current page. For details, see Embed console pages and share log data.