• prometheus-黑盒探针blackbox_exporter


    blackbox_exporter简介

    项目地址: https://github.com/prometheus/blackbox_exporter

    grafana: https://grafana.com/grafana/dashboards/13659

                  https://grafana.com/grafana/dashboards/9965

         blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。
    Blackbox_exporter 应用场景

    • HTTP 测试

              定义 Request Header 信息
              判断 Http status / Http Respones Header / Http Body 内容

    • TCP 测试

              业务组件端口状态监听
               应用层协议定义与监听

    • ICMP 测试

               主机探活机制

    • POST 测试

              接口联通性

    • SSL 证书过期时间

      

    部署

    下载软件

    wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.19.0/blackbox_exporter-0.19.0.linux-amd64.tar.gz
    
    tar xf blackbox_exporter-0.19.0.linux-amd64.tar.gz -C /opt
    
    ln -s /opt/blackbox_exporter-0.19.0.linux-amd64 /opt/blackbox_exporter

    准备启动文件

    [Unit]
    Description=blackbox_exporter Exporter
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    ExecStart=/opt/blackbox_exporter/blackbox_exporter --config.file=/opt/blackbox_exporter/blackbox.yml
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=blackbox_exporter
    [Install]
    WantedBy=default.target

    启动

    systemctl start blackbox_exporter.service 
    systemctl enable blackbox_exporter.service 
    
    systemctl status blackbox_exporter.service 

    示例

    URL测试

     http://192.168.168.106:9115/probe?target=https://www.baidu.com&module=http_2xx&debug=true 

    配置文件-http

      - job_name: 'blackbox-http'
    
        metrics_path: /probe
    
        params:
          module: [http_2xx]
        static_configs:
          - targets:
            - http://prometheus.io
            - https://www.baidu.com
            - http://192.168.168.106:3000
        relabel_configs:
          - source_labels: [__address__]
            target_label: __param_target
          - source_labels: [__param_target]
            target_label: instance
          - target_label: __address__
            replacement: 127.0.0.1:9115

    配置文件-ssh

      - job_name: 'blackbox-ssh'
        
        metrics_path: /probe
       
        params:
          module: [ssh_banner]
        static_configs:
          - targets:
            - 192.168.168.105
            - 192.168.168.106
        relabel_configs:
          - source_labels: [__address__]
            target_label: __param_target
          - source_labels: [__param_target]
            target_label: instance
          - target_label: __address__
            replacement: 192.168.168.106:9115

     配置文件-icmp

      - job_name: 'blackbox-icmp'
        metrics_path: /probe
        params:
          module: [icmp]
        static_configs:
          - targets:
            - 192.168.168.105
            - 192.168.168.106
            labels:
              instance: node_status
              group: 'node'
        relabel_configs:
          - source_labels: [__address__]
            target_label: __param_target
          - target_label: __address__
            replacement: 192.168.168.106:9115

    配置文件-端口状态

      - job_name: 'blackbox-port'
        metrics_path: /probe
        params:
          module: [tcp_connect]
        static_configs:
          - targets:
            - 192.168.168.105:3000
            labels:
              instance: 'port_status'
              group: 'tcp'
        relabel_configs:
          - source_labels: [__address__]
            target_label: __param_target
          - source_labels: [__param_target]
            target_label: instance
          - target_label: __address__
            replacement: 192.168.168.106:9115

    作者:闫世成

    出处:http://cnblogs.com/yanshicheng

    联系:yans121@sina.com

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,如有问题或建议,请多多赐教,非常感谢。
  • 相关阅读:
    echarts设置数据在轴线上显示
    LeetCode【189. 旋转数组】
    pycharm快捷键
    LeetCode【461. 汉明距离】
    LeetCode【1051. 高度检查器】
    LeetCode【509. 斐波那契数】
    LeetCode【1021. 删除最外层的括号】
    LeetCode【206. 反转链表】
    LeetCode【344. 反转字符串】
    tensorboard运行
  • 原文地址:https://www.cnblogs.com/yanshicheng/p/15211600.html
Copyright © 2020-2023  润新知