Prometheus 是主流开源监控系统,通过拉取方式采集指标,含时序数据库、PromQL、告警和可视化能力;安装后配置抓取目标,结合 node_exporter 暴露主机指标,用 PromQL 查询如 up 和 rate(),再通过 Alertmanager 实现 CPU 过载告警。

Prometheus 是目前最主流的开源监控系统,特别适合云原生和容器环境。它通过拉取(pull)方式采集指标,自带时序数据库、强大查询语言(PromQL)、告警规则和可视化能力,入门门槛不高,但需理清核心组件关系。
一、安装 Prometheus 服务端
最简单的方式是下载二进制包直接运行:
- 访问 https://prometheus.io/download/ 下载对应系统的最新版本(如 Linux amd64)
- 解压后进入目录,编辑 prometheus.yml 配置文件,确保至少包含默认抓取目标:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']登录后复制
保存后执行 ./prometheus --config.file=prometheus.yml,服务即启动,默认监听 http://localhost:9090
二、让被监控服务暴露指标(Exporter)
Prometheus 不直接监控应用,而是通过“Exporter”把各类数据转成标准格式供其拉取。常见用法:
- 监控本机基础指标:下载 node_exporter(同 Prometheus 官网下载),运行 ./node_exporter,默认暴露在 :9100/metrics
- 在 prometheus.yml 中添加 job:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']登录后复制
重启 Prometheus 或触发热重载(curl -X POST http://localhost:9090/-/reload),稍等片刻即可在 Web 界面 Targets 页面看到状态变为 UP。
三、写第一条 PromQL 查询并看图
打开 http://localhost:9090/graph,尝试输入:
标签: linux node curl amd 路由 解压 配置文件 igs
还木有评论哦,快来抢沙发吧~