一键部署Prometheus+Grafana+alertmanager对网站状态进行监控

在建设监控体系的过程中,针对一个系统的监控是多维度的,除了服务器资源状态、中间件状态、应用状态外,对系统访问状态的监控也是很有必要,可以在系统访问出现异常时第一时间通知到我们。本文介绍使用 Docker-compose 方式一键部署 Prometheus + Grafana + alertmanager + blackbox_exporter,实现黑盒测试(站点监控),docker-compose.yml 文件已上传至 Github ,直接启动即可。


1. 安装 docker-compose

Docker 和 Docker-Compose 安装方法参考: Docker二进制安装教程!-CSDN博客

2. 下载docker-compose.yml

因为某些原因,拉取失败可以多拉取几次

复制代码
$ git clone https://github.com/Public-Compose/Prometheus-Grafana.git

3. 启动 Prometheus 容器

各个组件的镜像已改为阿里源,境内可正常拉取

复制代码
$ cd Prometheus-Grafana
$ docker-compose up -d

4. 添加权限重启

复制代码
$ chmod 777 -R prometheus grafana alertmanager pushgateway blackbox_exporter
$ docker-compose restart

5. 地址测试

查一下容器状态是否都正常

复制代码
$ docker-compose ps

**「Prometheus访问地址:」**http://IP:9090

**「Grafana访问地址:」**http://IP:3000 账号: admin 密码: admin

**「Alertmanager访问地址:」**http://IP:9093

**「Pushgateway访问地址:」**http://IP:9091

**「blackbox访问地址:」**http://IP:9115

6. Grafana添加数据源

「选择 Configuration -- data sources -- Add data sources -- Prometheus」

「URL:」http://prometheus:9090

7. 导入模板 -- 9965

7.1 选择 Dashboards -- Import -- ID 输入9965,点击Load
7.2 选择数据源

8. 站点监控完成

可通过修改 Prometheus-Grafana\prometheus\blackbox 目录下的数据源文件调整监控站点信息,每30s自动刷新源数据

到此,对站点监控状态的可视化已完成,后续需根据通知方式配置告警器及 rules,如果使用AlertManager则需编写rules和安装webhook,也可参考我之前的文章直接使用夜莺(nightingale)进行告警配置。

相关推荐
微风◝3 小时前
12. grafana-Dashboard的Variable(过滤)使用
grafana
TDengine (老段)13 天前
使用 Prometheus 访问 TDengine ---
大数据·数据库·prometheus·时序数据库·iot·tdengine·涛思数据
枫桥听月13 天前
16.大数据监控
大数据·prometheus
广目软件13 天前
GM DC Monitor v2.0 卸载教程
服务器·网络·zabbix·prometheus
不太聪明的样子14 天前
c++ 项目使用 prometheus + grafana 进行实时监控
c++·grafana·prometheus
Detachym19 天前
CentOS下的运维监控Grafana部署
运维·centos·grafana
南夏一木子20 天前
性能测试——搭建Prometheus+Grafana平台
grafana·prometheus
奈斯ing20 天前
【prometheus+Grafana篇】基于Prometheus+Grafana实现postgreSQL数据库的监控与可视化
运维·数据库·信息可视化·grafana·prometheus
xixingzhe221 天前
docker compose安装Prometheus、Grafana
docker·grafana·prometheus
碧水澜庭23 天前
Prometheus+ Grafana 监控系统入门
grafana·prometheus