网站首页 > 教程文章 正文
blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。
Blackbox_exporter 可以对一下场景进行监控:
o HTTP 测试定义 Request Header 信息判断 Http status / Http Respones Header / Http Body 内容
o TCP 测试业务组件端口状态监听应用层协议定义与监听
o ICMP 测试主机探活机制
o POST 测试接口联通性SSL 证书过期时间
在之前的运维中,因为忘了更换证书有些服务挂了一会,虽然很快恢复了但是也让我出一身冷汗。一开始我是用shell写了一个脚本定时执行来监听证书的时间,后来发现blackbox-exporter可以对证书等多中黑盒状态进行探测,所以也应用到了线上,这个场景比较适用免费证书的应用,因为现在你在购买证书的时候一般到期前都会给你收集发短信一类的通知,云场景就更不用说了,部署完了之后会有消息通知的策略设置。
1.安装blackbox_exporter
# 创建文件夹
root@ubuntu2204-98:~# cd /usr/local/prometheus_monitor/
root@ubuntu2204-98:/usr/local/prometheus_monitor# mkdir blackbox_exporter
root@ubuntu2204-98:/usr/local/prometheus_monitor# cd blackbox_exporter
# 创建docker-compose文件,启动
root@ubuntu2204-98:/usr/local/prometheus_monitor/blackbox_exporter# vi docker-compose.yml
version: '3'
services:
blackbox_exporter:
image: prom/blackbox-exporter:master
ports:
- 9115:9115
restart: unless-stopped
root@ubuntu2204-98:/usr/local/prometheus_monitor/blackbox_exporter# docker-compose up -d2.创建blackbox监控Web列表
root@ubuntu2204-98:/usr/local/prometheus_monitor/blackbox_exporter# cd /usr/local/prometheus_monitor/prometheus
root@ubuntu2204-98:/usr/local/prometheus_monitor/prometheus# mkdir blackbox_monitor
root@ubuntu2204-98:/usr/local/prometheus_monitor/prometheus# cd blackbox_monitor
root@ubuntu2204-98:/usr/local/prometheus_monitor/prometheus/blackbox_monitor# vi blackbox-exporter.yaml
# 定义要监控的网站
- targets:
- https://gitlab.ccc.top # Target to probe with http.
- https://jenkins.ccc.top/login?from=%2F # Target to probe with https.
- https://chatnext.ccc.top # Target to probe with http on port 8080.
- https://drawio.ccc.top # Target to probe with http on path /healthz3.Prometheus加入blackbox
root@ubuntu2204-98:/usr/local/prometheus_monitor/prometheus/blackbox_monitor# cd ..
root@ubuntu2204-98:/usr/local/prometheus_monitor/prometheus# vi prometheus.yml
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.1.98:9115 # The blackbox exporter's real hostname:port.
static_configs:
file_sd_configs:
- files:
- /etc/prometheus/blackbox_monitor/blackbox-exporter.yaml4.导入模板
模板id:9965
image-20250831095800345
猜你喜欢
- 2025-09-28 阿里云工程师日常面对云服务器的必备工具与命令(附实操与源码)
- 2025-09-28 系统可观测性设计与Java实现详解_系统的可观察性
- 2025-09-28 Linux磁盘爆满紧急救援指南:5步清理释放50GB+小白也能轻松搞定
- 2025-09-28 可视化分布式监控系统 Prometheus + Grafana 快速搭建
- 2025-09-28 日志查询哪家强?用Loki 替换ELK没商量,是时候用这个轻量级方案
- 2025-09-28 十几年的java开发程序员了,还停留在curd吗?看看接下来能学什么
- 2025-09-28 Prometheus运维(Prometheus初始化设置,接入主机及进程监控)
- 2025-09-28 集群外部署Prometheus+Grafana监控K8S解析
- 2025-09-28 Go 项目的布局:你是怎么组织你的Go代码的?
- 2025-09-28 用开源软件,搭建类似向日葵或todesk的远程控制软件
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- mybatis plus page (35)
- vue @scroll (38)
- 堆栈区别 (33)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)
- redis aof rdb 区别 (33)
- 302跳转 (33)
- http method (35)
- js array splice (33)
