Merge pull request #1496 from serenashe/tt

Modified file-KubeSphere-alerting
This commit is contained in:
Sherlock113 2021-05-06 17:11:02 +08:00 committed by GitHub
commit 080319d1fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 76 deletions

View File

@ -1,7 +1,7 @@
---
title: "KubeSphere Alerting"
keywords: "Kubernetes, alertmanager, KubeSphere, alerting"
description: "Learn how to enable Alerting and Notification to identify any potential issues in advance before they take a toll on your business."
description: "Learn how to enable Alerting to identify any potential issues in advance before they take a toll on your business."
linkTitle: "KubeSphere Alerting"
weight: 6600
---

View File

@ -1,49 +1,39 @@
---
title: "KubeSphere 告警和通知系统"
keywords: "Kubernetes, alertmanager, KubeSphere, 告警, 通知"
description: "了解如何启用告警和通知功能,以便在潜在问题对您的业务造成影响之前提前识别这些问题。"
linkTitle: "KubeSphere 告警和通知"
title: "KubeSphere 告警系统"
keywords: "Kubernetes, alertmanager, KubeSphere, 告警"
description: "了解如何启用告警功能,以便在潜在问题对您的业务造成影响之前提前识别这些问题。"
linkTitle: "KubeSphere 告警系统"
weight: 6600
---
## 什么是 KubeSphere 告警和通知系统
## 什么是 KubeSphere 告警系统
告警和通知是可观测性的两个重要构件与监控和日志密切相关。KubeSphere 中的告警系统与其主动式故障通知 (Proactive Failure Notification) 系统相结合,使用户可以基于告警策略了解感兴趣的活动。当达到某个指标的预定义阈值时,会向预先配置的收件人发出告警,您可以自行设置通知方式,包括 Email、企业微信和 Slack 等。有了功能强大的告警和通知系统,您就可以迅速发现并提前解决潜在问题,避免您的业务受影响。
告警是可观测性的重要构件与监控和日志密切相关。KubeSphere 中的告警系统与其主动式故障通知 (Proactive Failure Notification) 系统相结合,使用户可以基于告警策略了解感兴趣的活动。当达到某个指标的预定义阈值时,会向预先配置的收件人发出告警。因此您需要预先配置通知方式包括邮件、Slack、钉钉、企业微信和 Webhook。有了功能强大的告警和通知系统,您就可以迅速发现并提前解决潜在问题,避免您的业务受影响。
有关更多信息,请参见[告警策略](../../project-user-guide/alerting/alerting-policy/)和[告警信息](../../project-user-guide/alerting/alerting-message/)。
{{< notice note >}}
建议同时启用告警和通知功能,这样用户可以及时收到告警通知。
{{</ notice >}}
## 在安装前启用告警和通知系统
## 在安装前启用告警系统
### 在 Linux 上安装
当您在 Linux 上安装多节点 KubeSphere 时,需要创建一个配置文件,该文件列出了所有 KubeSphere 组件。
1. 基于[在 Linux 上安装 KubeSphere](../../installing-on-linux/introduction/multioverview/) 的教程,您需要创建一个默认文件 `config-sample.yaml`。通过执行以下命令修改该文件:
1. [在 Linux 上安装 KubeSphere](../../installing-on-linux/introduction/multioverview/) 时,您需要创建一个默认文件 `config-sample.yaml`。通过执行以下命令修改该文件:
```bash
vi config-sample.yaml
```
{{< notice note >}}
如果您采用 [All-in-One 安装](../../quick-start/all-in-one-on-linux/),则不需要创建 `config-sample.yaml` 文件因为可以直接创建集群。一般来说All-in-One 模式是为那些刚接触 KubeSphere 并希望熟悉系统的用户而准备的。如果您想在该模式下启用告警和通知系统(例如用于测试),请参考[下面的部分](#在安装后启用告警和通知系统),查看如何在安装后启用告警和通知系统。
如果您采用 [All-in-One 安装](../../quick-start/all-in-one-on-linux/),则不需要创建 `config-sample.yaml` 文件因为可以直接创建集群。一般来说All-in-One 模式针对那些刚接触 KubeSphere 并希望熟悉系统的用户。如果您想在该模式下启用告警系统(例如用于测试),请参考[下面的部分](#在安装后启用告警系统),查看如何在安装后启用告警系统。
{{</ notice >}}
2. 在该文件中,搜寻到 `alerting` `notification`并将 `enabled``false` 改为 `true`。完成后保存文件。
2. 在该文件中,搜寻到 `alerting` 并将 `enabled``false` 改为 `true`。完成后保存文件。
```yaml
alerting:
enabled: true # Change "false" to "true"
notification:
enabled: true # Change "false" to "true"
enabled: true # 将“false”更改为“true”。
```
3. 使用配置文件创建集群:
3. 使用配置文件创建集群:
```bash
./kk create cluster -f config-sample.yaml
@ -51,23 +41,21 @@ weight: 6600
### 在 Kubernetes 上安装
在 Kubernetes 上安装 KubeSphere 的过程与教程[在 Kubernetes 上安装 KubeSphere](../../installing-on-kubernetes/introduction/overview/) 中的说明大致相同,不同之处是需要先在 [cluster-configuration.yaml](https://github.com/kubesphere/ks-installer/releases/download/v3.1.0/cluster-configuration.yaml) 文件中启用告警和通知系统(可选组件)
[在 Kubernetes 上安装 KubeSphere](../../installing-on-kubernetes/introduction/overview/) 时,您可以先在 [cluster-configuration.yaml](https://github.com/kubesphere/ks-installer/releases/download/v3.1.0/cluster-configuration.yaml) 文件中启用告警系统。
1. 下载 [cluster-configuration.yaml](https://github.com/kubesphere/ks-installer/releases/download/v3.1.0/cluster-configuration.yaml) 文件,然后打开并开始编辑。
1. 下载 [cluster-configuration.yaml](https://github.com/kubesphere/ks-installer/releases/download/v3.1.0/cluster-configuration.yaml) 文件并进行编辑。
```bash
vi cluster-configuration.yaml
```
2. 在该本地 `cluster-configuration.yaml` 文件中,搜寻到 `alerting``notification`,并将 `enabled``false` 改为 `true`,启用它们。完成后保存文件。
2. 在该本地 `cluster-configuration.yaml` 文件中,搜寻到 `alerting`,将 `enabled``false` 更改为 `true` 以启用告警系统。完成后保存文件。
```yaml
alerting:
enabled: true # Change "false" to "true"
notification:
enabled: true # Change "false" to "true"
enabled: true # 将“false”更改为“true”。
```
3. 执行以下命令开始安装:
```bash
@ -76,11 +64,11 @@ weight: 6600
kubectl apply -f cluster-configuration.yaml
```
## 在安装后启用告警和通知系统
## 在安装后启用告警系统
1. `admin` 身份登录控制台。点击左上角的**平台管理**,选择**集群管理**。
1. 使用 `admin` 用户登录控制台。点击左上角的**平台管理**,选择**集群管理**。
![集群管理](/images/docs/zh-cn/enable-pluggable-components/kubesphere-alerting-and-notification/clusters-management.png)
![cluster-management1](/images/docs/zh-cn/enable-pluggable-components/kubesphere-alerting-and-notification/cluster-management1.png)
2. 点击**自定义资源 CRD**,在搜索栏中输入 `clusterconfiguration`。点击结果查看其详细页面。
@ -90,18 +78,16 @@ weight: 6600
3. 在**资源列表**中,点击 `ks-installer` 右边的三个点,选择**编辑配置文件**。
![编辑 YAML](/images/docs/zh-cn/enable-pluggable-components/kubesphere-alerting-and-notification/edit-yaml.PNG)
![edit-yaml1](/images/docs/zh-cn/enable-pluggable-components/kubesphere-alerting-and-notification/edit-yaml1.png)
4. 在该 YAML 文件中,搜寻到 `alerting``notification`,将 `enabled``false` 改为 `true`。完成后,点击右下角的**更新**,保存配置。
4. 在该 YAML 文件中,搜寻到 `alerting`,将 `enabled``false` 改为 `true`。完成后,点击右下角的**更新**,保存配置。
```yaml
alerting:
enabled: true # Change "false" to "true"
notification:
enabled: true # Change "false" to "true"
enabled: true # 将“false”更改为“true”。
```
5. 您可以通过执行以下命令,使用 Web Kubectl 工具来检查安装过程:
5. 您可以使用 Web Kubectl 工具执行以下命令来检查安装过程:
```bash
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
@ -113,39 +99,6 @@ weight: 6600
## 验证组件的安装
{{< tabs >}}
如果您在**集群管理**页面可以看到**告警消息**和**告警策略**,说明安装成功,因为安装组件之后才会显示这两部分。
{{< tab "在仪表板中验证组件的安装" >}}
如果您在下图所示界面中可以看到**告警消息**和**告警策略**,说明安装成功,因为安装组件之后才会显示这两部分。
![告警](/images/docs/zh-cn/enable-pluggable-components/kubesphere-alerting-and-notification/alerting.PNG)
{{</ tab >}}
{{< tab "通过 kubectl 验证组件的安装" >}}
执行以下命令来检查 Pod 的状态:
```bash
kubectl get pod -n kubesphere-alerting-system
```
如果组件运行成功,输出结果可能如下:
```bash
NAME READY STATUS RESTARTS AGE
alerting-client-744c794979-xvsbz 1/1 Running 2 36m
alerting-db-ctrl-job-jwdsh 0/1 Completed 0 36m
alerting-db-init-job-sj2nv 0/1 Completed 0 36m
alerting-executor-59ff88f484-2l57d 2/2 Running 0 36m
alerting-manager-5dc9d6cd46-jshkw 1/1 Running 0 36m
alerting-watcher-dcb87b665-sm87b 1/1 Running 0 36m
notification-db-ctrl-job-phxsx 0/1 Completed 3 36m
notification-db-init-job-8q5rf 0/1 Completed 0 36m
notification-deployment-748897cbdf-2djpr 1/1 Running 0 36m
```
{{</ tab >}}
{{</ tabs >}}
![alerting1](/images/docs/zh-cn/enable-pluggable-components/kubesphere-alerting-and-notification/alerting1.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB