# Prometheus **Repository Path**: jerrryWang/prometheus ## Basic Information - **Project Name**: Prometheus - **Description**: Prometheus 是一款强大的监控系统和时间序列数据库,用于实时收集和处理指标数据,支持高度灵活的查询语言。 一键化安装Prometheus、Alertmanager、Grafana、Node_exporter - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-13 - **Last Updated**: 2025-09-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Prometheus 监控系统部署套件 ![Prometheus](Prometheus.jpg) ## 📦 组件清单 | 组件 | 版本 | 官方地址 | | ------------- | ------ | ----------------------------------------------------- | | Prometheus | 2.53.3 | [官网](https://prometheus.io/) | | Alertmanager | 0.28.1 | [GitHub](https://github.com/prometheus/alertmanager) | | Grafana | 11.5.2 | [官网](https://grafana.com/) | | Node Exporter | 1.9.0 | [GitHub](https://github.com/prometheus/node_exporter) | ## 🚀 快速部署指南 ### 前置条件 - Linux 系统(推荐 CentOS 7+/Ubuntu 18.04+) - root 权限 - 预装 wget、tar 等基础工具 ### 1. 克隆仓库 ```bash cd /opt/ && git clone https://gitee.com/jerrryWang/prometheus.git ``` ### 2. 初始化环境 ```bash # 创建专用系统用户 useradd -M -s /usr/sbin/nologin prometheus # 创建数据目录结构 mkdir -p /opt/prometheus/{prometheus/data,alertmanager/data,grafana/{data,logs},node_exporter/data} # 设置目录权限 chown -R prometheus:prometheus /opt/prometheus ``` ### 3. 部署服务 ```bash # 复制systemd服务文件 cp /opt/prometheus/*.service /etc/systemd/system/ # 重载服务配置 systemctl daemon-reload # 启动所有服务 systemctl enable --now {prometheus,alertmanager,grafana,node_exporter} # 验证服务状态 ss -tunlp | grep -E "9090|9093|3000|9100" ``` ## 🔧 服务管理 ### 常用命令 ```bash # 查看服务状态 systemctl status prometheus alertmanager grafana node_exporter # 重启单个服务 systemctl restart prometheus # 热重载配置(Prometheus) curl -X POST http://localhost:9090/-/reload ``` ### 默认访问地址 | 服务 | 地址 | 默认凭证 | | :------------ | :----------------------------------------------------- | :---------- | | Prometheus | [http://服务器IP:9090](http://xn--ip-fr5c86lx7z:9090/) | - | | Alertmanager | [http://服务器IP:9093](http://xn--ip-fr5c86lx7z:9093/) | - | | Grafana | [http://服务器IP:3000](http://xn--ip-fr5c86lx7z:3000/) | admin/admin | | Node Exporter | [http://服务器IP:9100](http://xn--ip-fr5c86lx7z:9100/) | - | ## ⚠️ 生产环境注意事项 ### 安全加固 ```bash # 防火墙配置示例 firewall-cmd --permanent --add-port=9090/tcp \ --add-port=9093/tcp \ --add-port=3000/tcp \ --add-port=9100/tcp firewall-cmd --reload ``` ### 数据备份 ```bash # 每日备份任务(crontab -e) 0 2 * * * tar -czf /backup/prometheus-$(date +\%F).tar.gz /opt/prometheus/prometheus/data ``` ### 资源限制 ```bash # 示例:限制Prometheus内存使用 sudo systemctl edit prometheus [Service] MemoryHigh=4G MemoryMax=6G ``` ## 🛠️ 配置文件结构 ``` prometheus/ ├── alertmanager │ ├── alertmanager.yml # 告警路由配置 │ └── templates/ # 告警模板目录 ├── prometheus │ ├── prometheus.yml # 主配置文件 │ └── rules/ # 告警规则目录 └── grafana └── dashboards/ # Grafana仪表板配置 ``` ## 🔍 组件验证指南 | 组件 | 验证命令 | 预期输出特征 | | :------------ | :---------------------------------------- | :--------------------------- | | Prometheus | `curl http://localhost:9090/-/ready` | "Prometheus Server is ready" | | Alertmanager | `curl -s http://localhost:9093/-/healthy` | "OK" | | Node Exporter | `curl http://localhost:9100/metrics` | 包含 node_cpu 等主机指标 | ## ⚙️ 配置管理 ### 核心配置文件路径 | 组件 | 主配置文件路径 | 热加载方式 | | :----------- | :---------------------------------------------- | :-------------------------------------------- | | Prometheus | `/opt/prometheus/prometheus/prometheus.yml` | `curl -X POST http://localhost:9090/-/reload` | | Alertmanager | `/opt/prometheus/alertmanager/alertmanager.yml` | `systemctl restart alertmanager` | | Grafana | `/opt/prometheus/grafana/conf/defaults.ini` | `systemctl restart grafana` | ## 📚 学习资源 - [Prometheus 官方文档](https://prometheus.io/docs/introduction/overview/) - [Grafana 仪表板市场](https://grafana.com/grafana/dashboards/) - [Alertmanager 最佳实践](https://prometheus.io/docs/alerting/latest/alertmanager/) > 💡 提示:部署完成后请及时修改Grafana默认密码! ## 许可证 [MIT License](LICENSE) © JerrryWang