Querying Application Logs


When the log service is configured and running normally, you can query application logs by seach conditions.

Querying Logs

Take the following steps to query the logs of the target application:

  1. From the left navigation bar, select Log Center > Log Search.

  2. Select the application name, the environment, and the cluster for the application.

  3. Select the start date and end date to query the logs.

  4. Enter the filtering conditions to query logs. ES searching syntax is supported.

  5. Click the Search button. To query the latest log information, select Auto refresh. The log information that matches the filtering conditions will be displayed.

    ../../_images/querying_log.png
  6. Click View context after the log records to view the selected log and the logs before and after it.

Using Advanced Query

使用日志搜索提供的高级查询功能,可将多种查询过滤条件以ES支持的语法快速组装成查询语句,通过执行该语句来满足复杂业务场景下的日志查询。

  1. 点击日志查询页面中的 更多条件,展开 高级查询 输入框。

    ../../_images/querying_log_advanced.png
  2. 高级查询 输入框中,输入查询语句。点击回车或输入部分关键字,系统将弹出智能提示,可以通过鼠标或键盘操作选中对应提示,选中的关键字将高亮展示在输入框中。

    ../../_images/querying_log_advanced_1.png
  3. 如需按 Pod 过滤日志信息,从 Pod 下拉菜单中选择应用的 Pod。该 Pod 的查询过滤条件将出现在高级查询输入框中。如果之前已经输入查询语句,则会自动在已输入的查询语句上加入括号并通过 AND 关键字进行连接。

  4. 如需按日志信息等级过滤日志,从 Level 下拉菜单中选择日志等级,高级查询输入框中将生成对应的查询条件。如果之前已经输入查询语句,则会自动在已输入的查询语句上加入括号并通过 AND 关键字进行连接。

    ../../_images/querying_log_advanced_2.png
  5. 点击 搜索 按钮,搜索应用日志。

Operator Logic

高级查询支持通过逻辑连接符和括号将多段单独查询语句进行连接。必须使用括号来合并操作符才能产生正确的布尔逻辑,并且括号前后需要加空格。各逻辑连接符的说明如下:

  • AND:前后语句的查询结果取交集后返回
  • OR:前后语句的查询结果取并集后返回
  • NOT:标识后续语句不允许包含在结果里
  • ( ):优先执行括号内的逻辑


逻辑连接符的优先级顺序为:( ) > NOT > AND > OR。


更多查询语法可以参考 Elastic Search