mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-11 20:31:18 +00:00
style: apply global formatting fixes (struct, spacing, zhlint)
This commit is contained in:
@@ -4,13 +4,17 @@
|
||||
|
||||
在传统架构中,我们通常关注主机的 CPU、内存、磁盘 IO 等指标。而在容器环境下,除了主机层面的监控,我们更关注容器级别的资源使用情况、服务的运行状态以及编排系统的健康状况。
|
||||
|
||||
## 概述
|
||||
|
||||
总体概述了以下内容。
|
||||
|
||||
## 常见的监控方案
|
||||
|
||||
目前主流的容器监控方案包括:
|
||||
|
||||
* **cAdvisor**: Google 开源的容器资源监控工具,Docker 原生支持。
|
||||
* **Prometheus**: CNCF 毕业项目,云原生时代最流行的监控系统。
|
||||
* **Grafana**: 强大的可视化平台,常与 Prometheus 配合使用。
|
||||
* **ELK/EFK Stack**: 主要用于日志管理,但也能提供一定的监控能力。
|
||||
* **cAdvisor**:Google 开源的容器资源监控工具,Docker 原生支持。
|
||||
* **Prometheus**:CNCF 毕业项目,云原生时代最流行的监控系统。
|
||||
* **Grafana**:强大的可视化平台,常与 Prometheus 配合使用。
|
||||
* **ELK/EFK Stack**:主要用于日志管理,但也能提供一定的监控能力。
|
||||
|
||||
本章将重点介绍如何使用 Prometheus 和 Grafana 搭建一套完整的容器监控系统。
|
||||
|
||||
@@ -8,18 +8,18 @@ Prometheus 和 Grafana 是目前最流行的开源监控组合,前者负责数
|
||||
|
||||
Prometheus 的主要组件包括:
|
||||
|
||||
* **Prometheus Server**: 核心组件,负责收集和存储时间序列数据。
|
||||
* **Exporters**: 负责向 Prometheus 暴露监控数据(如 Node Exporter, cAdvisor)。
|
||||
* **Alertmanager**: 处理报警发送。
|
||||
* **Pushgateway**: 用于支持短生命周期的 Job 推送数据。
|
||||
* **Prometheus Server**:核心组件,负责收集和存储时间序列数据。
|
||||
* **Exporters**:负责向 Prometheus 暴露监控数据 (如 Node Exporter,cAdvisor)。
|
||||
* **Alertmanager**:处理报警发送。
|
||||
* **Pushgateway**:用于支持短生命周期的 Job 推送数据。
|
||||
|
||||
### 快速部署
|
||||
|
||||
我们可以使用 Docker Compose 快速部署一套 Prometheus + Grafana 监控环境。
|
||||
|
||||
#### 1. 准备配置文件
|
||||
#### 1。准备配置文件
|
||||
|
||||
创建 `prometheus.yml`:
|
||||
创建 `prometheus.yml`:
|
||||
|
||||
```yaml
|
||||
global:
|
||||
@@ -39,9 +39,9 @@ scrape_configs:
|
||||
- targets: ['cadvisor:8080']
|
||||
```
|
||||
|
||||
#### 2. 编写 Docker Compose 文件
|
||||
#### 2。编写 Docker Compose 文件
|
||||
|
||||
创建 `compose.yaml`(或 `docker-compose.yml`):
|
||||
创建 `compose.yaml` (或 `docker-compose.yml`):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
@@ -88,7 +88,7 @@ networks:
|
||||
monitoring:
|
||||
```
|
||||
|
||||
#### 3. 启动服务
|
||||
#### 3。启动服务
|
||||
|
||||
运行以下命令:
|
||||
|
||||
@@ -99,11 +99,11 @@ $ docker compose up -d
|
||||
启动后,访问以下地址:
|
||||
|
||||
* Prometheus: `http://localhost:9090`
|
||||
* Grafana: `http://localhost:3000` (默认账号密码: admin/admin)
|
||||
* Grafana:`http://localhost:3000` (默认账号密码:admin/admin)
|
||||
|
||||
### 配置 Grafana 面板
|
||||
|
||||
1. 在 Grafana 中添加 Prometheus 数据源,URL 填写 `http://prometheus:9090`。
|
||||
2. 导入现成的 Dashboard 模板,例如 [Node Exporter Full](https://grafana.com/grafana/dashboards/1860) (ID: 1860) 和 [Docker Container](https://grafana.com/grafana/dashboards/193) (ID: 193)。
|
||||
2. 导入现成的 Dashboard 模板,例如 [Node Exporter Full](https://grafana.com/grafana/dashboards/1860) (ID:1860) 和 [Docker Container](https://grafana.com/grafana/dashboards/193) (ID:193)。
|
||||
|
||||
这样,你就拥有了一个直观的容器监控大屏。
|
||||
|
||||
Reference in New Issue
Block a user