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:
@@ -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