全球热门:Prometheus监控之Blackbox_exporter

2022-12-12 16:13:36 来源:51CTO博客


【资料图】

一、简介

Blackbox_exporter是Prometheus官方提供的一个exporter,可以监控HTTP,HTTPS,DNS,TCP,ICMP和gRPC等目标实例,从而实现对被监控节点进行监控和数据采集。下载地址:https://github.com/prometheus/blackbox_exportertar -xvf blackbox_exporter-0.22.0.linux-amd64.tar.gzmv blackbox_exporter-0.22.0.linux-amd64 blackbox_exporter/usr/local/blackbox_exporter/blackbox_exporter \    --config.file="/usr/local/blackbox_exporter/blackbox.yml" \    --web.listen-address="10.10.10.10:9115" &>blackbox_exporter.log &启动参数有--web.config.file="" #就可以配置TLS--web.listen-address="10.10.10.10:9115" #指定ip和端口设置开机自启vi /usr/lib/systemd/system/blackbox_exporter.service[Unit]Description=Prometheus blackbox exporterAfter=network.target[Service]Type=simpleUser=rootGroup=rootRestart=on-failureExecStart=/usr/local/blackbox_exporter/blackbox_exporter \    --config.file="/usr/local/blackbox_exporter/blackbox.yml" \    --web.listen-address="10.10.10.10:9115"[Install]WantedBy=multi-user.targetsystemctl daemon-reloadsystemctl restart blackbox_exporter.service

二、搭建

blackbox_exporter的监控,包括URL,ICMP,TCP等。都是先在prometheus设置监控内容,再转发到blackbox_exporter的地址,最后得出监控结果。

1、URL监控

在prometheus服务器添加url监控工作,末尾指定blackbox_exporter地址:scrape_configs:  - job_name: "blackbox"    metrics_path: /probe    params:      module: [http_2xx]  # Look for a HTTP 200 response.    static_configs:      - targets:        - http://baidu.com    # Target to probe with http.        - https://baidu.com   # Target to probe with https.        - http://example.com:8080 # Target to probe with http on port 8080.    relabel_configs:      - source_labels: [__address__]        target_label: __param_target      - source_labels: [__param_target]        target_label: instance      - target_label: __address__        replacement: 10.10.10.10:9115  # The blackbox exporter"s real hostname:port.        在blackbox_exporter服务器查看最近URL探测:

2、ICPM监控

ICMP就是Ping使用的协议,可以探测IP是否在线:scrape_configs:  - job_name: "ping_status"    metrics_path: /probe    params:      module: [icmp]     static_configs:      - targets:        - 192.168.10.131        - 192.168.10.132        - 192.168.10.133        labels:           instance: "ping_status"          group: "icmp"    relabel_configs:      - source_labels: [__address__]        target_label: __param_target      - source_labels: [__param_target]        target_label: ip      - target_label: __address__        replacement: 10.10.10.10:9115        在blackbox_exporter服务器查看最近ICMP探测:

3、PORT监控

Port端口用于检测服务器端口是否开启,服务是否可用:scrape_configs:  - job_name: "port_status"    metrics_path: /probe    params:      module: [tcp_connect]     static_configs:      - targets: ["192.168.10.131:22","192.168.10.132:3306","192.168.10.133:8080"]        labels:           instance: "port_status"          group: "port"    relabel_configs:      - source_labels: [__address__]        target_label: __param_target      - source_labels: [__param_target]        target_label: ip      - target_label: __address__        replacement: 10.10.10.10:9115在blackbox_exporter服务器查看最近Port探测:

标签: 下载地址 数据采集 服务器端口

上一篇:世界观焦点:【秒杀购物商城业务服务】「分布式架构服务」盘点中间件服务的高可用模式及集群技术的方案分析
下一篇:容器指南之自定义 Confluence 容器镜像