监控域名与证书过期
部署Black Exporter
这里使用二进制部署Black Exporter
# 下载安装wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.16.0/blackbox_exporter-0.16.0.linux-amd64.tar.gztar -xvf blackbox_exporter-0.16.0.linux-amd64.tar.gzmv blackbox_exporter-0.16.0.linux-amd64/ /data/redis_exporter# 创建配置文件cat > /data/black_exporter/black_exporter.yml << EOFmodules:http_2xx:prober: httptimeout: 20shttp:preferred_ip_protocol: "ip4"http_post_2xx_query:prober: httptimeout: 20shttp:preferred_ip_protocol: "ip4" ##使用ipv4method: POSTheaders:Content-Type: application/json ##header头body: '{"hmac":"","params":{"publicFundsKeyWords":"xxx"}}' ##传参tls_connect_tls:prober: tcptimeout: 5stcp:tls: truetcp_connect:prober: tcptimeout: 5s#pop3s_banner:prober: tcptcp:query_response:- expect: "^+OK"tls: truetls_config:insecure_skip_verify: falsessh_banner:prober: tcptcp:query_response:- expect: "^SSH-2.0-"irc_banner:prober: tcptcp:query_response:- send: "NICK prober"- send: "USER prober prober prober :prober"- expect: "PING :([^ ]+)"send: "PONG ${1}"- expect: "^:[^ ]+ 001"icmp:prober: icmptimeout: 20sEOF# 配置systemdcat > /etc/systemd/system/blackbox_exporter.service <<EOF[Unit]Description=blackbox_exporterDocumentation=https://prometheus.io/After=network.target[Service]Type=simpleUser=prometheusExecStart=/data/blackbox_exporter/blackbox_exporter --config.file=/data/blackbox_exporter/blackbox.ymlRestart=on-failure[Install]WantedBy=multi-user.targetEOF# 启动服务systemctl enable blackbox_exporter.servicesystemctl start blackbox_exporter.servicesystemctl status blackbox_exporter.service# 配置Consul自动发现cat > /data/consul/server1/config/blackbox-exporter.json <<EOF{"service":{"name":"blackbox-exporter","tags":["prod","blackbox-exporter"],"address": "172.26.42.229","port":9115,"check":{"http":"http://172.26.42.229:9115","interval":"10s"},"token":"your_token"}}EOF# 热加载Consul配置consul reload# Grafana导入Dashboard-ID:7587
