blackbox_exporter 监控组件
【1】Blackbox_exporter 简介
(1.1)实现功能
blackbox-exporter项目地址:https://github.com/prometheus/blackbox_exporter
blackbox_exporter 是 Prometheus 官方提供的一个 exporter,可以监控 HTTP、 HTTPS,、DNS、 TCP 、ICMP 等目标实例,从而实现对被监控节点进行监控 和数据采集。promethes调用blackbox_exporter去访问目标监控服务器,实现指标的采集
prometheus blackbox_exporter下载地址:Download | Prometheus
HTTP/HTPPS:URL/API 可用性检测
TCP:端口监听检测
ICMP:主机存活检测
DNS:域名解析
黑盒监控和白盒监控:
黑盒监控,关注的是实时状态,一般都是正在发生的事件,比如网站访问不了、磁盘无法写入数据等。即黑盒监控的重点是能对正在发生的故障进行告警。常见的黑盒监控包括HTTP探针、TCP探针等用于检测站点或者服务的可访问性,以及访问效率等。
白盒监控,关注的是原因,也就是系统内部的一些运行指标数据,例如nginx响应时长、存储I/O负载等
监控系统要能够有效的支持百盒监控和黑盒监控,通过白盒能够了解系统内部的实际运行状态,以及对监控指标的观察能够预判出可能出现的潜在问题,从而对潜在的不确定因素进行提前处理避免问题发生;
而通过黑盒监控,可以在系统或服务发生故障时快速通知相关人员进行处理。
(1.2)下载和部署blackbox_exporter
https://github.com/prometheus/blackbox_exporter
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.23.0/blackbox_exporter-0.23.0.linux-amd64.tar.gz tar xf blackbox_exporter-0.23.0.linux-amd64.tar.gz -C /usr/local/ ln -sv /usr/local/blackbox_exporter-0.23.0.linux-amd64 /usr/local/blackbox_exporter /usr/local/blackbox_exporter/blackbox_exporter -h #查看帮助信息
(1.3)blackbox_exporter 配置文件解析
官方解释: https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md
modules: http_2xx: prober: http http_post_2xx: prober: http http: method: POST tcp_connect: prober: tcp pop3s_banner: prober: tcp tcp: query_response: - expect: "^+OK" tls: true tls_config: insecure_skip_verify: false ssh_banner: prober: tcp tcp: query_response: - expect: "^SSH-2.0-" irc_banner: prober: tcp tcp: query_response: - send: "NICK prober" - send: "USER prober prober prober :prober" - expect: "PING :([^ ]+)" send: "PONG ${1}" - expect: "^:[^ ]+ 001" icmp: prober: icmp
运行 blackbox exporter 时,需要用户提供探针的配置信息,这些配置信息可能是一些自定义的 HTTP 头信息,也可能是探测时需要的一些 TSL(秘钥证书) 配置。
也可能是探针本身的验证行为.在 blackbox exporter 每一个探针配置称为一个 module,并且以 YAML 配置文件的形式提供给 blackbox exporter。
每一个 module 主要包含以下配置内容,探针类型(prober),验证访问超时时间(timeout),以及当前探针的具体配置项:
# 探针类型: http https tcp dns icmp prober: <prober_string> #必选 # 超时时间: [timeout: <duration>] #默认单位秒 # 探针的详细配置,最多只能配置其中一个 [ http: <http_probe> ] [ tcp: <tcp_probe> ] [ dns: <dns_probe> ] [ icmp: <icmp_probe> ] <http_probe>可配置参数 # 此探针接受的状态代码。 默认为2xx。 [ valid_status_codes: <int>, ... | default = 2xx ] # 此探针接受的 HTTP 版本. [ valid_http_versions: <string>, ... ] #探针将使用的HTTP方法。 [ method: <string> | default = "GET" ] # 为探针设置的HTTP标头。 headers: [ <string>: <string> ... ] # 探针是否将遵循任何重定向 [ no_follow_redirects: <boolean> | default = false ] # 如果存在SSL,则探测失败。 [ fail_if_ssl: <boolean> | default = false ] # 如果不存在SSL,则探测失败。 [ fail_if_not_ssl: <boolean> | default = false ] # 如果响应主体与正则表达式匹配,则探测失败。 fail_if_body_matches_regexp: [ - <regex>, ... ] # 如果响应主体与正则表达式不匹配,则探测失败。 fail_if_body_not_matches_regexp: [ - <regex>, ... ] # 如果响应头与正则表达式匹配,则探测失败。 对于具有多个值的标头,如果*至少一个*匹配,则失败。 fail_if_header_matches: [ - <http_header_match_spec>, ... ] # 如果响应头与正则表达式不匹配,则探测失败。 对于具有多个值的标头,如果* none *不匹配,则失败。 fail_if_header_not_matches: [ - <http_header_match_spec>, ... ] # HTTP探针的TLS协议的配置。 tls_config: [ <tls_config> ] # 目标的HTTP基本身份验证凭据。 basic_auth: [ username: <string> ] [ password: <secret> ] # 目标的承载令牌。 [ bearer_token: <secret> ] # 目标的承载令牌文件 [ bearer_token_file: <filename> ] # 用于连接到目标的HTTP代理服务器。 [ proxy_url: <string> ] # HTTP探针的IP协议(ip4,ip6) [ preferred_ip_protocol: <string> | default = "ip6" ] [ ip_protocol_fallback: <boolean> | default = true ] # 探针中使用的HTTP请求的主体。 body: [ <string> ] ################################################################### <http_header_match_spec> header: <string>, regexp: <regex>, [ allow_missing: <boolean> | default = false ]
(1.4)结合 prometheus
blackbox_exporter访问验证
prometheus-server服务验证
grafana导入模板
模板:ID-13587、ID-9965
【参考文档】
本文来自博客园,作者:PunchLinux,转载请注明原文链接:https://www.cnblogs.com/punchlinux/p/17035311.html
- blackbox_exporter prometheus blackbox exporterblackbox_exporter prometheus blackbox exporter blackbox_exporter kubernetes prometheus blackbox blackbox_exporter blackbox-exporter blackbox exporter url blackbox-exporter blackbox exporter面板 blackbox exporter prometheus-node_exporter prometheus-node_exporter prometheus exporter elasticsearch prometheus dashboard exporter