Prometheus笔记-安装blackbox_exporter
1.Prometheus笔记-安装2.Prometheus笔记-Label标签3.Prometheus笔记-file_sd_config4.Prometheus笔记-监控docker容器5.Prometheus笔记-Grafana可视化6.Prometheus笔记-安装Node_exporter7.Prometheus笔记-配置文件字段解析
8.Prometheus笔记-安装blackbox_exporter
9.Prometheus笔记-设置Basic_auth登录校验10.Prometheus笔记-Docker部署Prometheus11.Prometheus笔记-监控Nginx12.Prometheus笔记-告警规则配置Blackbox Exporter是Prometheus社区提供的官方黑盒监控解决方案,其允许用户通过:HTTP、HTTPS、DNS、TCP以及ICMP 的方式对网络进行探测。我们可以利用这个exporter定时访问业务系统某个接口来确定服务是否存活
下载
[root@VM-24-9-centos exporter_package]# wget https://ghproxy.com/https://github.com/prometheus/blackbox_exporter/releases/download/v0.23.0/blackbox_exporter-0.23.0.linux-amd64.tar.gz --2023-01-09 21:26:39-- https://ghproxy.com/https://github.com/prometheus/blackbox_exporter/releases/download/v0.23.0/blackbox_exporter-0.23.0.linux-amd64.tar.gz Resolving ghproxy.com (ghproxy.com)... 141.147.152.25 Connecting to ghproxy.com (ghproxy.com)|141.147.152.25|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10831812 (10M) [application/octet-stream] Saving to: ‘blackbox_exporter-0.23.0.linux-amd64.tar.gz’ 100%[===========================================================================================================================================>] 10,831,812 2.25MB/s in 5.2s 2023-01-09 21:26:46 (1.97 MB/s) - ‘blackbox_exporter-0.23.0.linux-amd64.tar.gz’ saved [10831812/10831812]
安装
# 解压 [root@VM-24-9-centos exporter_package]# tar -zxvf blackbox_exporter-0.23.0.linux-amd64.tar.gz blackbox_exporter-0.23.0.linux-amd64/ blackbox_exporter-0.23.0.linux-amd64/blackbox.yml blackbox_exporter-0.23.0.linux-amd64/LICENSE blackbox_exporter-0.23.0.linux-amd64/NOTICE blackbox_exporter-0.23.0.linux-amd64/blackbox_exporter # 备份配置文件 [root@VM-24-9-centos exporter_package]# cd blackbox_exporter-0.23.0.linux-amd64/ [root@VM-24-9-centos blackbox_exporter-0.23.0.linux-amd64]# ls blackbox_exporter blackbox.yml LICENSE NOTICE [root@VM-24-9-centos blackbox_exporter-0.23.0.linux-amd64]# cp blackbox.yml blackbox.yml_init [root@VM-24-9-centos blackbox_exporter-0.23.0.linux-amd64]# ls blackbox_exporter blackbox.yml blackbox.yml_init LICENSE NOTICE
blackbox_exporter配置文件demo
scrape_configs: - job_name: 'blackbox' metrics_path: /probe params: module: [http_2xx] # 加载一个模块为http_2xx的模块,这个模块用于查看http状态为200的响应 static_configs: - targets: - http://prometheus.io # 目标地址为http协议 - https://prometheus.io # 目标地址为https协议 - http://example.com:8080 # 目标地址为http协议且端口为8080 relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 127.0.0.1:9115 # The blackbox exporter's real hostname:port.
修改black_exporter配置文件
[root@VM-24-9-centos blackbox_exporter-0.23.0.linux-amd64]# vi blackbox.yml modules: http_2xx:# 这个名字需要和Prometheus中的params对应 prober: http # 探针类型:http tcp dns icmp timeout: 10s
新增Prometheus配置文件job_name
- job_name: "blackbox_exporter" metrics_path: /probe # 默认为/probe params: module: [http_2xx] # 加载一个模块为http_2xx的模块,这个模块用于查看http状态为200的响应 static_configs: - targets: # 要监控的目标地址 - http://www.baidu.com/ - http://prometheus.io relabel_configs: # 以下内容不要修改 - source_labels: [__address__] target_label: __param_target - source_labels: [__address__] target_label: instance - target_label: __address__ replacement: localhost:9115 # 该地址为blackbox_exporter服务的ip及端口
启动
[root@VM-24-9-centos exporter_package]# cd blackbox_exporter-0.23.0.linux-amd64/ [root@VM-24-9-centos blackbox_exporter-0.23.0.linux-amd64]# ./blackbox_exporter --config.file="blackbox.yml" ts=2023-01-09T14:39:45.219Z caller=main.go:78 level=info msg="Starting blackbox_exporter" version="(version=0.23.0, branch=HEAD, revision=26fc98b9c6db21457653ed752f34d1b7fb5bba43)" ts=2023-01-09T14:39:45.219Z caller=main.go:79 level=info build_context="(go=go1.19.3, user=root@f360719453e3, date=20221202-12:26:32)" ts=2023-01-09T14:39:45.220Z caller=main.go:91 level=info msg="Loaded config file" ts=2023-01-09T14:39:45.220Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9115 ts=2023-01-09T14:39:45.220Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9115 # 把blackbox_exporter服务挂到后台 nohup ./blackbox_exporter --config.file="blackbox.yml" &
显示效果
这里正好对应上面新增的两个监控目标
具体请求的结果可以访问 http://ip:9155访问
作者:jruing
出处:https://www.cnblogs.com/jruing/p/17057656.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
本文来自博客园,作者:Jruing,转载请注明原文链接:https://www.cnblogs.com/jruing/p/17057656.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具