网络探测:Blackbox Exporter

发布时间:2023-10-02 点击:212
系统运维
网络探测:blackbox exporter
什么是 blackbox exporter?
blackbox exporter 是 prometheus 社区提供的 官方黑盒监控解决方案,其允许用户通过: http\\\\https\\\\dns\\\\tcp\\\\icmp的方式对网络进行探测.
以 docker 方式运行 blackbox exporter
拉取镜像
docker pull prom/blackbox-exporter查看 dockerfile(这是一个好习惯)
$ cat check_docker_file.sh#!/bin/bashexport path=$pathif [ $# -eq 1 ];then docker history --format {{.createdby}} --no-trunc=true $1 |sed s/\\\\/bin\\\\/sh\\\\ -c\\\\ \\\\#(nop)\\\\ //g|sed s/\\\\/bin\\\\/sh\\\\ -c/run/g | tac else echo sh obtain_dockerfile.sh $docker_imagefi$ sh check_docker_file.sh prom/blackbox-exporter:latestadd file:b265aa0ea2ef7ff1f4a3e087217e75aca2c90f5c345406299664cc7969b2b28e in / cmd [sh] maintainer the prometheus authors <prometheus-developers@googlegroups.com>copy dir:b1c1c3c551755544b818d03ad9136b137ca12c48393ba5cdd58d7f845647e042 in / label maintainer=the prometheus authors <prometheus-developers@googlegroups.com> arg arch=amd64 arg os=linuxcopy file:2bfe91827ebb767bc51f40cd84675a3c315d9da8a70f6d8071c806e0b2b1ee73 in /bin/blackbox_exportercopy file:6e820c2d591d3433d139b66241b74e9b7ffc90c9e120bac49cf97014e16f070a in /etc/blackbox_exporter/config.yml expose 9115 entrypoint [/bin/blackbox_exporter] cmd [--config.file=/etc/blackbox_exporter/config.yml]运行 blackbox exporter
docker run -id --name blackbox-exporter -p 9115:9115 prom/blackbox-exporterblackbox 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 icmpprober: <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: [ <string> ] [ <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> ]###########################

正版office每年都要收费吗 正版office收费标准
金山云Q1营收强劲同比增长64.5%
腾讯云服务器续费流程
域名注册商不给转移域名吗?域名怎么转移注册商?
美国服务器,做外贸站的都推荐
上海web云服务器合算
浪潮人工智能开发平台AIStation,支持AI训练与推理一站式交付
阿里云gpu云服务器租用