prometheus blackbox_exporter安装

目录


一、准备工作

1.1 安装或关闭以下服务

关闭防火墙等
linux时间校对

1.2 本次安装环境

配置信息 说明
服务器IP地址 192.168.1.10
交换机IP地址 192.168.10.1
上网行为管理IP地址 192.168.20.1
系统版本 CentOS7.4
内核 ml-3.10.0
go版本 1.19.4

在本次安装前,先安装好prometheus+grafana。
prometheus+grafana安装文档

二、安装blackbox_exporter

2.1 下载并解压

bash 复制代码
wget -c  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

2.2配置

bash 复制代码
mv blackbox_exporter-0.23.0.linux-amd64 /home/blackbox_exporter   #修改文件名称
cd /home/blackbox_exporter/         
 ./blackbox_exporter    #启动snmp_exporter

2.3测试

访问测试http://192.168.1.10:9115/

三、配置blackbox_exporter

3.1配置blackbox.yml

bash 复制代码
 vim /home/blackbox_exporter/blackbox.yml
modules:
  http_2xx_ip4:
    prober: http
    timeout: 5s
    http:
      preferred_ip_protocol: "ip4"
  http_2xx:
    prober: http
  http_post_2xx:
    prober: http
    http:
      method: get
  tcp_connect:
    prober: tcp
  pop3s_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^+OK"
      tls: true
      tls_config:
        insecure_skip_verify: false
  grpc:
    prober: grpc
    grpc:
      tls: true
      preferred_ip_protocol: "ip4"
  grpc_plain:
    prober: grpc
    grpc:
      tls: false
      service: "service1"
  ssh_banner:
    prober: tcp
    tcp:
      query_response:
"/home/blackbox_exporter/blackbox.yml" 54L, 1004C                                                                 1,1          顶端
modules:
  http_2xx_ip4:
    prober: http
    timeout: 5s
    http:
      preferred_ip_protocol: "ip4"
  http_2xx:
    prober: http
  http_post_2xx:
    prober: http
    http:
      method: get
  tcp_connect:
    prober: tcp
  pop3s_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^+OK"
      tls: true
      tls_config:
        insecure_skip_verify: false
  grpc:
    prober: grpc
    grpc:
      tls: true
      preferred_ip_protocol: "ip4"
  grpc_plain:
    prober: grpc
    grpc:
      tls: false
      service: "service1"
  ssh_banner:
    prober: tcp
    tcp:
      query_response:
      - expect: "^SSH-2.0-"
      - send: "SSH-2.0-blackbox-ssh-check"
  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
  icmp_ttl5:
    prober: icmp
    timeout: 5s
    icmp:
      ttl: 5

3.2 开启blackbox_exporter

bash 复制代码
./blackbox_exporter &  
curl 'localhost:9115/probe?target=baidu.com'   #开启后,可以测试下是否正常。返回probe_success 1则正常

3.3配置prometheus.yml

bash 复制代码
vim /usr/local/prometheus/prometheus.yml 
   -  job_name: "http"
      metrics_path: /probe
      scrape_interval: 60s
      params:
         module: [http_2xx_ip4]
      static_configs:
        - targets:
          - https://www.baidu.com
          - https://google.com
      relabel_configs:
        - source_labels: [__address__]
          target_label: __param_target
        - source_labels: [__param_target]
          target_label: instance
        - target_label: __address__
          replacement: 192.168.1.10:9115

配置完毕后启动prometheus.yml,访问192.168.1.10:9090,选择status→targets查看

四、其他

4.1server returned HTTP status 400 Bad Request 报错

解决

prometheus.yml 中将replacement:127.0.0.1:9115修改成本机地址

4.2 google.com检测码返回probe_success 0

参考这篇文章添加以下配置

modules:

http_2xx_ip4:

prober: http

timeout: 5s

http:

preferred_ip_protocol: "ip4"

相关推荐
Cherry的跨界思维6 天前
【AI测试全栈:质量】47、Vue+Prometheus+Grafana实战:打造全方位AI监控面板开发指南
vue.js·人工智能·ci/cd·grafana·prometheus·ai测试·ai全栈
AC赳赳老秦6 天前
云原生AI故障排查新趋势:利用DeepSeek实现高效定位部署报错与性能瓶颈
ide·人工智能·python·云原生·prometheus·ai-native·deepseek
予枫的编程笔记6 天前
【Kafka高级篇】Kafka监控不踩坑:JMX指标暴露+Prometheus+Grafana可视化全流程
kafka·grafana·prometheus·可观测性·jmx·kafka集群调优·中间件监控
AC赳赳老秦7 天前
预见2026:DeepSeek与云平台联动的自动化流程——云原生AI工具演进的核心引擎
人工智能·安全·云原生·架构·自动化·prometheus·deepseek
认真的薛薛7 天前
13.k8s中Prometheus监控集群及其服务,endpoint暴露服务,es采集k8s日志
elasticsearch·kubernetes·prometheus
A-刘晨阳7 天前
K8S部署kube-state-metrics + CAdvisor 并使用 Prometheus 监控 Kubernetes 指标
运维·云原生·kubernetes·云计算·prometheus·cadvisor·state-metrics
AC赳赳老秦8 天前
多模态 AI 驱动办公智能化变革:DeepSeek 赋能图文转写与视频摘要的高效实践
java·ide·人工智能·python·prometheus·ai-native·deepseek
AC赳赳老秦8 天前
2026云原生AI规模化趋势预测:DeepSeek在K8s集群中的部署与运维实战
运维·人工智能·云原生·架构·kubernetes·prometheus·deepseek