恢弘志士之气,不宜妄自菲薄。这篇文章主要讲述prometheusblackbox_exporter相关的知识,希望能为你提供帮助。
一、概述1、 HTTP 测试
- 定义 Request Header 信息
- 判断 Http status / Http Respones Header / Http Body 内容
- 业务组件端口状态监听
- 应用层协议定义与监听
- 主机探活机制
- 接口联通性
以linux系统为例,下载编译好的二进制包,解压使用:
1、下载并解压
# wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.19.0/blackbox_exporter-0.19.0.linux-amd64.tar.gz
# tar -zxvf blackbox_exporter-0.19.0.linux-amd64.tar.gz
# cd blackbox_exporter-0.19.0.linux-amd64/
2、验证是否安装成功
# ./blackbox_exporter --version
blackbox_exporter, version 0.19.0 (branch: HEAD, revision: 5d575b88eb12c65720862e8ad2c5890ba33d1ed0)
build user:root@2b0258d5a55a
build date:20210510-12:56:44
go version:go1.16.4
platform:linux/amd64
3、启动blackbox_exporter
nohup ./blackbox_exporter &
4、验证是否启动成功
# netstat -utpln|grep blackbox
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp600 :::9115:::*LISTEN25185/./blackbox_ex
5、创建systemcd服务(centos7系统可以用)
$ vim /lib/systemd/system/blackbox_exporter.service[Unit]
Description=blackbox_exporter
After=network.target[Service]
User=root
Type=simple
ExecStart=/usr/local/blackbox_exporter/blackbox_exporter --config.file=/usr/local/blackbox_exporter/blackbox.yml
Restart=on-failure[Install]
WantedBy=multi-user.target
三、prometheus.yml中加入blackbox_exporter 1、监控主机存活状态
# vim prometheus.yml
- job_name: crawler_status
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets: [\'10.45.3.8\',\'10.45.3.9\',\'10.45.3.10\',\'10.45.3.11\']
labels:
instance: node_status
group: \'node\'
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
2、监控主机端口存活状态
- job_name: \'crawler_port_status\'
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: [\'10.45.3.8:3128\']
labels:
instance: \'port_status\'
group: \'tcp\'
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
3、监控网站状态
- job_name: qianxin_web_status
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: [\'https://www.qianxin.com\']
labels:
instance: qianxin_web_status
group: \'web\'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 127.0.0.1:9115- job_name: baidu_web_status
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: [\'https://www.baidu.com\']
labels:
instance: baidu_web_status
group: \'web\'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 127.0.0.1:9115- job_name: jd_web_status
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: [\'https://www.jd.com\']
labels:
instance: jd_web_status
group: \'web\'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 127.0.0.1:9115
4、检查配置文件是否书写正确
# ./promtool check config prometheus.yml
5、重启prometheus 6、查看targets界面四、grafana中加入blackbox_exporter监控数据 1、安装grafana
# docker run -d -p 3000:3000 --name grafana grafana/grafana
2、添加数据源
文章图片
文章图片
文章图片
五、grafana中加入blackbox_exporter监控数据 1、添加模版https://grafana.com/grafana/dashboards/9965
https://grafana.com/grafana/dashboards/9719
文章图片
此模板需要安装饼状图插件 下载地址 https://grafana.com/grafana/plugins/grafana-piechart-panel
安装插件,重启grafana生效。
# docker exec -it grafana grafana-cli plugins install grafana-piechart-panel
# docker restart grafana
【prometheusblackbox_exporter】
文章图片
推荐阅读
- 认识Java项目开发效率工具 Lombok
- MongoDB认证与授权
- kube-eventer事件监控
- 你会用ES6,那倒是用啊!
- 想了解Xtrabackup备份原理和常见问题分析,看这篇就够了
- Dynamics 365层级数据的定义展示与查询
- 实体关联起来查询可以不通过关系(Lookup字段)吗()
- Flutter 多引擎支持 PlatformView 以及线程合并解决方案
- 深入 iOS 静态链接器— ld64