prometheus 监控 服务是否可用 可用性监控 blackbox_exporte
blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。
blackbox_exporter 应用场景
-
ICMP 测试
主机探活机制 -
HTTP 测试
定义 Request Header 信息
判断 Http status / Http Respones Header / Http Body 内容 -
TCP 测试
业务组件端口状态监听
应用层协议定义与监听 -
POST 测试
接口联通性 -
SSL 证书过期时间
-
自定义测试(扩展)
下载
安装
不说了,安装请看另外一篇:prometheus 监控 主机存活 监控 blackbox_exporter
在Prometheus上添加blackbox_exporter的配置
- job_name: 服务可用性监测
metrics_path: /probe
params:
module: [http_2xx]
file_sd_configs:
- refresh_interval: 10s
files:
- "/data/prometheus-2.22.1.linux-amd64/conf.d/http_status.yml"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 127.0.0.1:9115
- source_labels: [__param_target]
target_label: instance
添加配置文件 conf.d/http_status.yml
cat conf.d/http_status.yml
- targets: ['http://192.168.80.176:8061/carsoa-assembly/actuator/info','http://192.168.80.176:8005/carsoa-auth/actuator/info','http://192.168.80.176:8066/carsoa-bpm/actuator/info']
labels:
group: 'bjj'
重新加载prometheus配置
测试配置是否正确
$./promtool check config prometheus.yml
Checking prometheus.yml
SUCCESS: 0 rule files found
重新加载Prometheus配置
$ curl -X POST http://127.0.0.1:9090/-/reload (启用了--web.enable-lifecycle选项)
查看加入的监控信息
访问 http://127.0.0.1:9090/targets
Grafana中加入 blackbox_exporter监控数据
导入blackbox_exporter模板
此模板为9965号模板,数据源选择Prometheus 模板下载地址
https://grafana.com/grafana/dashboards/9965
注意
此模板需要安装饼状图插件 下载地址 https://grafana.com/grafana/plugins/grafana-piechart-panel
安装插件,重启grafana生效。
$ grafana-cli plugins install grafana-piechart-panel
$ service grafana-server restart