Merge pull request #1857 from serenashe/ud18

Update docs: Log query
This commit is contained in:
KubeSphere CI Bot 2021-10-09 11:02:00 +08:00 committed by GitHub
commit d6bdbac06d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 62 additions and 78 deletions

View File

@ -1,6 +1,6 @@
---
title: "Log Query"
keywords: 'KubeSphere, Kubernetes, log'
keywords: 'KubeSphere, Kubernetes, log, query'
description: 'Query Kubernetes logs from toolbox'
linkTitle: "Log Query"
weight: 15100
@ -8,7 +8,7 @@ weight: 15100
The logs of applications and systems can help you better understand what is happening inside your cluster and workloads. The logs are particularly useful for debugging problems and monitoring cluster activities. KubeSphere provides a powerful and easy-to-use logging system which offers users the capabilities of log collection, query and management from the perspective of tenants. The tenant-based logging system is much more useful than Kibana since different tenants can only view their own logs, leading to better security. Moreover, the KubeSphere logging system filters out some redundant information so that tenants can only focus on logs that are useful to them.
This tutorial demonstrates how to use the log query function, including the interface, search parameters and detail pages.
This tutorial demonstrates how to use the log query function, including the interface, search parameters and details pages.
## Prerequisites
@ -16,68 +16,60 @@ You need to enable the [KubeSphere Logging System](../../pluggable-components/lo
## Enter the Log Query Interface
1. The log query function is available for all users. Log in to the console with any account, hover over the **Toolbox** in the lower-right corner and select **Log Search**.
1. The log query function is available for all users. Log in to the console with any account, hover over <img src="/images/docs/toolbox/log-query/toolbox.png" width='20' /> in the lower-right corner and select **Log Search**.
![log-query-guide](/images/docs/toolbox/log-query/log-query-guide.png)
2. In the displayed dialog box, you can see a time histogram of log numbers, a cluster selection drop-down list and a log search box.
2. As shown in the pop-up window, you can see a time histogram of log numbers, a cluster selection drop-down list and a log search bar.
![log-query-interface](/images/docs/toolbox/log-query/log-query-interface.png)
![log-search](/images/docs/toolbox/log-query/log-search.png)
{{< notice note >}}
- KubeSphere supports log queries on each cluster separately if you have enabled the multi-cluster feature. You can switch the target cluster using the drop-down list next to the log search bar.
- Supported fields in the log search bar:
- **Keyword**
- **Project**
- **Workload**
- **Pod**
- **Container**
- **Time Range**
- The keyword field supports the query of keyword combinations. For example, you can use `Error`, `Fail`, `Fatal`, `Exception`, and `Warning` together to query all the exception logs.
- The keyword field supports exact query and fuzzy query. The fuzzy query provides case-insensitive fuzzy matching and retrieval of full terms by the first half of a word or phrase based on the ElasticSearch segmentation rules. For example, you can retrieve the logs containing `node_cpu_total` by searching the keyword `node_cpu` instead of the keyword `cpu`.
{{</ notice >}}
3. You can customize the query time range by selecting **Time Range** in the log search bar. Alternatively, click on the bars in the time histogram, and KubeSphere will use the time range of that bar for log queries.
![log-query-time-range](/images/docs/toolbox/log-query/log-query-time-range.png)
{{< notice note >}}
- KubeSphere supports log queries on each cluster separately if you have enabled the [multi-cluster feature](../../multicluster-management/). You can click <img src="/images/docs/toolbox/log-query/drop-down-list.png" width='20' /> on the left of the search box and select a target cluster.
- KubeSphere stores logs for last seven days by default.
- Each cluster has its own log retention period which can be set separately. You can modify it in `ClusterConfiguration`. Refer to [KubeSphere Logging System](../../pluggable-components/logging/) for more details.
{{</ notice >}}
3. You can click the search box and enter a condition to search for logs by keyword, project, workload, Pod, container, or time range (for example, use `Time Range:Last 10 minutes` to search for logs within the last 10 minutes). Alternatively, click on the bars in the time histogram, and KubeSphere will use the time range of that bar for log queries.
![log-search-list](/images/docs/toolbox/log-query/log-search-list.png)
{{< notice note >}}
- The keyword field supports the query of keyword combinations. For example, you can use `Error`, `Fail`, `Fatal`, `Exception`, and `Warning` together to query all the exception logs.
- The keyword field supports exact query and fuzzy query. The fuzzy query provides case-insensitive fuzzy matching and retrieval of full terms by the first half of a word or phrase based on the ElasticSearch segmentation rules. For example, you can retrieve the logs containing `node_cpu_total` by searching the keyword `node_cpu` instead of the keyword `cpu`.
- Each cluster has its own log retention period which can be set separately. You can modify it in `ClusterConfiguration`. For more information, see [KubeSphere Logging System](../../pluggable-components/logging/).
{{</ notice >}}
## Use Search Parameters
1. You can provide as many fields as possible to narrow down your search results. Below is an example of a log query on the cluster `product` with the keyword `error` in the project `kubesphere-system` within `last 12 hours`.
1. You can enter multiple conditions to narrow down your search results.
![log-query-log-search](/images/docs/toolbox/log-query/log-query-log-search.png)
![log-search-conditions](/images/docs/toolbox/log-query/log-search-conditions.png)
2. It returns logs of 13 rows with the corresponding time, project, pod and container information all displayed.
3. Click any one of the results from the list. Drill into its detail page and inspect the log from this Pod, including the complete context on the right. It is convenient for developers in terms of debugging and analyzing.
3. Click any one of the results from the list. Drill into its details page and inspect the log from this Pod, including the complete context on the right. It is convenient for developers in terms of debugging and analyzing.
![log-search-details-page](/images/docs/toolbox/log-query/log-search-details-page.png)
{{< notice note >}}
The log query interface supports dynamic refreshing with 5s, 10s or 15s, and allows users to export logs to a local file for further analysis (in the top-right corner).
- The log query interface supports dynamic refreshing with 5s, 10s, or 15s.
- You can click <img src="/images/docs/toolbox/log-query/export-logs.png" width='20' /> in the upper-right corner to export logs to a local file for further analysis.
{{</ notice >}}
![log-query-log-detail](/images/docs/toolbox/log-query/log-query-log-detail.png)
{{</ notice >}}
4. As you can see from the left panel, you can switch between Pods and inspect its containers within the same project from the drop-down list. In this case, you can detect if any abnormal Pods affect other Pods.
4. In the left panel, you can click <img src="/images/docs/toolbox/log-query/drop-down-list.png" width='20' /> to switch between Pods and inspect its containers within the same project. In this case, you can detect if any abnormal Pods affect other Pods.
![log-query-inspect-other-pods](/images/docs/toolbox/log-query/log-query-inspect-other-pods.png)
## Drill into the Detail Page
## Drill into the Details Page
1. If the log looks abnormal, you can drill into the Pod detail page or container detail page to further inspect container logs, resource monitoring graphs and events.
In the left panel, you can click <img src="/images/docs/toolbox/log-query/view-detail-page.png" width='20' /> to view the Pod details page or container details page.
![log-query-drill](/images/docs/toolbox/log-query/log-query-drill.png)
The following figure shows the Pod details page:
2. Inspect the container detail page as follows. At the same time, it allows you to open the terminal to debug the container directly.
![pod-details-page](/images/docs/toolbox/log-query/pod-details-page.png)
![log-query-drill-container](/images/docs/toolbox/log-query/log-query-drill-container.png)
The following figure shows the container details page. You can click **Terminal** in the upper-left corner to open the terminal and debug the container.
![container-detail-page](/images/docs/toolbox/log-query/container-detail-page.png)

View File

@ -1,6 +1,6 @@
---
title: "日志查询"
keywords: 'KubeSphere, Kubernetes, 日志'
keywords: 'KubeSphere, Kubernetes, 日志, 查询'
description: '了解如何快速执行日志查询,追踪集群的最新日志。'
linkTitle: "日志查询"
weight: 15100
@ -16,68 +16,60 @@ weight: 15100
## 进入日志查询界面
1. 所有用户都可以使用日志查询功能。使用任意帐户登录控制台,在右下角的**工具箱**图标上悬停,然后在弹出菜单中选择**日志查询**。
![进入日志查询](/images/docs/zh-cn/toolbox/log-query/log-query-guide.PNG)
1. 所有用户都可以使用日志查询功能。使用任意帐户登录控制台,在右下角的 <img src="/images/docs/zh-cn/toolbox/log-query/toolbox.png" width='20' /> 上悬停,然后在弹出菜单中选择**日志查询**。
2. 在弹出窗口中,您可以看到日志数量的时间直方图、集群选择下拉列表以及日志查询栏。
![日志查询界面](/images/docs/zh-cn/toolbox/log-query/log-query-interface.PNG)
![log-search](/images/docs/zh-cn/toolbox/log-query/log-search.png)
{{< notice note >}}
- 如果您启用了[多集群功能](../../multicluster-management/)KubeSphere 支持对每个集群分别进行日志查询。您可以点击搜索栏左侧的 <img src="/images/docs/zh-cn/toolbox/log-query/drop-down-list.png" width='20' /> 切换目标集群。
- KubeSphere 默认存储最近七天内的日志。
{{</ notice >}}
3. 您可以点击搜索栏并输入搜索条件,可以按照消息、企业空间、项目、资源类型、资源名称、原因、类别或时间范围搜索事件(例如,输入`时间范围:最近 10 分钟`来搜索最近 10 分钟的事件。或者点击时间直方图中的柱状图KubeSphere 会使用该柱状图的时间范围进行日志查询。
![log-search-list](/images/docs/zh-cn/toolbox/log-query/log-search-list.png)
{{< notice note >}}
- 如果您启用了多集群功能KubeSphere 支持对每个集群分别进行日志查询。您可以使用日志搜索栏旁边的下拉列表切换目标集群。
- 日志搜索栏中支持以下字段:
- **关键字**
- **项目**
- **工作负载**
- **容器组**
- **容器**
- **时间范围**
- 关键字字段支持关键字组合查询。例如,您可以同时使用 `Error`、`Fail`、`Fatal`、`Exception` 和 `Warning` 来查询所有异常日志。
- 关键字字段支持精确匹配和模糊匹配。模糊匹配不区分大小写,并且根据 ElasticSearch 分段规则,通过单词或词组的前半部分来检索完整术语。例如,您可以通过搜索关键字 `node_cpu`(而不是 `cpu`)来检索包含 `node_cpu_total` 的日志。
{{</ notice >}}
3. 您可以在日志搜索栏中选择**时间范围**来自定义查询时间范围。或者点击时间直方图中的柱状图KubeSphere 会使用该柱状图的时间范围进行日志查询。
![log-query-time-range](/images/docs/zh-cn/toolbox/log-query/log-query-time-range.PNG)
{{< notice note >}}
- KubeSphere 默认存储最近七天内的日志。
- 每个集群都有自己的日志保留期限,可单独设置,您可以在 `ClusterConfiguration` 中进行修改。有关详细信息,请参考 [KubeSphere 日志系统](../../pluggable-components/logging/)。
{{</ notice >}}
## 使用搜索参数
1. 您可以提供尽可能多的字段来缩小搜索结果。以在集群 `product` 的项目 `kubesphere-system` 中查询最近 12 小时内包含关键字 `error` 的日志为例,如下图所示
1. 您可以输入多个条件来缩小搜索结果。
![搜索日志](/images/docs/zh-cn/toolbox/log-query/log-query-log-search.PNG)
![log-search-conditions](/images/docs/zh-cn/toolbox/log-query/log-search-conditions.png)
2. 查询返回 13 行日志,并显示了相应的时间、项目、容器组(即 Pod和容器信息
2. 点击列表中的任一结果,进入它的详情页面,查看该容器组 (Pod) 的日志,包括右侧的完整内容,便于开发者分析和排除故障
3. 点击列表中的任一结果,进入它的详情页面,查看该 Pod 的日志,包括右侧的完整内容,便于开发者分析和排除故障。
![log-search-details-page](/images/docs/zh-cn/toolbox/log-query/log-search-details-page.png)
{{< notice note >}}
日志查询界面支持每 5 秒、10 秒或 15 秒动态刷新一次,并且用户可以将日志导出至本地文件进行进一步分析(点击右上角按钮)。
- 日志查询界面支持每 5 秒、10 秒或 15 秒动态刷新一次。
- 您可以点击右上角的 <img src="/images/docs/zh-cn/toolbox/log-query/export-logs.png" width='20' /> 将日志导出至本地文件进行进一步分析。
{{</ notice >}}
![日志详情](/images/docs/zh-cn/toolbox/log-query/log-query-log-detail.PNG)
{{</ notice >}}
4. 您在左侧面板可以通过下拉列表切换 Pod 并查看其在同一个项目中的容器,从而查看是否有任何异常 Pod 影响到其他 Pod。
4. 在左侧面板中,您可以点击 <img src="/images/docs/zh-cn/toolbox/log-query/drop-down-list.png" width='20' /> 切换 Pod 并查看其在同一个项目中的容器,从而查看是否有任何异常 Pod 影响到其他 Pod。
![查看其它 Pod](/images/docs/zh-cn/toolbox/log-query/log-query-inspect-other-pods.PNG)
## 进入详情页面
1. 如果日志看起来异常,您可以进入 Pod 详情页面或容器详情页面,进一步查看容器日志、资源监控图以及事件
在左侧面板,您可以点击 <img src="/images/docs/zh-cn/toolbox/log-query/view-detail-page.png" width='20' /> 查看 Pod 详情页面或容器详情页面
![进入详情页面](/images/docs/zh-cn/toolbox/log-query/log-query-drill.PNG)
下图是 Pod 详情页面示例:
2. 如下图所示,查看容器详情页面。同时,您还可以打开终端直接为容器排除故障。
![pod-details-page](/images/docs/zh-cn/toolbox/log-query/pod-details-page.png)
![进入容器](/images/docs/zh-cn/toolbox/log-query/log-query-drill-container.png)
下图是容器详情页面示例。您可以点击右上角的**终端**打开终端为容器排除故障。
![container-detail-page](/images/docs/zh-cn/toolbox/log-query/container-detail-page.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB