“Blackbox exporter”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
(未显示同一用户的6个中间版本)
第18行: 第18行:
 
<pre>
 
<pre>
 
这个可以参考 laradock 用变量哦
 
这个可以参考 laradock 用变量哦
#填写你的 blackboxip
+
#填写你的 blackboxip,可能和我的不一样
 
  vim  prometheus/prometheus.yml
 
  vim  prometheus/prometheus.yml
  
         replacement: "10.3.10.124:9115"  # Blackbox exporter.
+
         #replacement: "10.3.10.124:9115"  # Blackbox exporter.
         #replacement: "blackbox_exporter:9115"  # Blackbox exporter.
+
         replacement: "blackbox_exporter:9115"  # Blackbox exporter.
  
 
重载
 
重载
第34行: 第34行:
 
     [ password: <secret> ]
 
     [ password: <secret> ]
 
</pre>
 
</pre>
 +
 
=* grafana =
 
=* grafana =
  
第58行: 第59行:
  
  
 +
https://blog.csdn.net/qq_25934401/article/details/84325356
 +
 +
 +
=* 配置参考 =
 +
<pre> cp config.yml config.ymltodaygood
 +
#add to config.yml
 +
  - job_name: 'blackbox'
 +
    metrics_path: /probe
 +
    params:
 +
      module: [http_2xx]  # Look for a HTTP 200 response.
 +
    static_configs:
 +
      - targets:
 +
        - https://hk.search.yahoo.com
 +
        #- https://pagertree.com
 +
        #- https://prometheus.io
 +
        labels:
 +
          instance: user_status
 +
          grop: 'web'
 +
    relabel_configs:
 +
      - source_labels: [__address__]
 +
        target_label: __param_target
 +
      - source_labels: [__param_target]
 +
        target_label: instance
 +
      - target_label: __address__
 +
        #replacement: "localhost:9115"  # Blackbox exporter.
 +
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
 +
      - target_label: region
 +
        replacement: "local"
 +
 +
 +
  - job_name: 'blackbox http_post_2xx'
 +
    metrics_path: /probe
 +
    params:
 +
      module: [http_post_2xx]  # Look for a HTTP 200 response.
 +
    static_configs:
 +
      - targets:
 +
        - https://m-api.126.com/api/v1/m/coin/rank/thirty
 +
        #- https://linuxchina.net
 +
    relabel_configs:
 +
      - source_labels: [__address__]
 +
        target_label: __param_target
 +
      - source_labels: [__param_target]
 +
        target_label: instance
 +
      - target_label: __address__
 +
        #replacement: "localhost:9115"  # Blackbox exporter.
 +
        #replacement: "10.3.10.124:9115"  # Blackbox exporter.
 +
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
 +
      - target_label: region
 +
        replacement: "local"
 +
 +
 +
</pre>
 +
官方配置eg  这个官方的放进去也是报错 老是重启 哈哈
 +
https://github.com/prometheus/blackbox_exporter/blob/master/example.yml
 +
 +
 +
blackbox exporter 配置文件解读
 +
 +
官方解释:https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md
 +
 +
 +
git clone https://github.com/PagerTree/prometheus-grafana-alertmanager-example.git
 +
cd "$DIRECTORY"
 +
 +
=* 进阶=
 +
 +
[https://cloud.tencent.com/developer/article/1584310 网络探测:Blackbox Exporter]
 +
 +
介绍几种应用场景  这个有空要试一下
 +
 +
 +
 +
[https://blog.csdn.net/u014029783/article/details/80001862?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-5.nonecase blackbox_exporter源码阅读]
 +
 +
 +
网络探测监控的操作还有HTTPS DNS TCP ICMP  SSH etc
 +
<pre>
 +
监控主机存活状态
 +
 +
编辑prometheus配置文件
 +
 +
 +
最后一行添加
 +
 +
最后一行添加
 +
 +
  - job_name: node_status
 +
    metrics_path: /probe
 +
    params:
 +
      module: [icmp]
 +
    static_configs:
 +
      - targets: ['10.165.94.31']
 +
        labels:
 +
          instance: node_status
 +
          group: 'node'
 +
    relabel_configs:
 +
      - source_labels: [__address__]
 +
        target_label: __param_target
 +
      - target_label: __address__
 +
        replacement: 172.19.155.133:9115
 +
 +
注意:10.165.94.31是被监控端ip,172.19.155.133是Blackbox_exporter
 +
 +
监控主机端口存活状态
 +
  - job_name: 'prometheus_port_status'
 +
    metrics_path: /probe
 +
    params:
 +
      module: [tcp_connect]
 +
    static_configs:
 +
      - targets: ['172.19.155.133:8765']
 +
        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: 172.19.155.133:9115
 +
 +
 +
监控网站状态
 +
 +
  - job_name: web_status
 +
    metrics_path: /probe
 +
    params:
 +
      module: [http_2xx]
 +
    static_configs:
 +
      - targets: ['http://www.baidu.com']
 +
        labels:
 +
          instance: user_status
 +
          group: 'web'
 +
    relabel_configs:
 +
      - source_labels: [__address__]
 +
        target_label: __param_target
 +
      - target_label: __address__
 +
        replacement: 172.19.155.133:9115
 +
 +
</pre>
 +
 +
 +
=* see also=
  
 +
[https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md Blackbox exporter configuration]
  
 +
[https://github.com/prometheus/blackbox_exporter/blob/master/example.yml Blackbox exporter configuration Exmaple]
  
https://blog.csdn.net/qq_25934401/article/details/84325356
+
https://github.com/prometheus/blackbox_exporter
 +
 
 +
https://yunlzheng.gitbook.io/prometheus-book/part-ii-prometheus-jin-jie/exporter/commonly-eporter-usage/install_blackbox_exporter
 +
 
 +
[https://blog.frognew.com/2018/02/prometheus-blackbox-exporter.html 使用Prometheus的blackbox_exporter进行网络监控]
 +
 
 +
[https://blog.csdn.net/qq_25934401/article/details/84325356 Prometheus 监控之 Blackbox_exporter黑盒监测 [icmp、tcp、http(get\post)、dns、ssl证书过期时间<nowiki>]</nowiki>]
 +
[[category:ops]] [[category:container]]

2020年12月10日 (四) 07:23的最新版本

* intra

Blackbox Exporter是Prometheus社区提供的官方黑盒监控解决方案,其允许用户通过:HTTP、HTTPS、DNS、TCP以及ICMP的方式对网络进行探测

* install

** From source

** Using Docker

docker-compose 自带了 也可以自己安装在其它机器上

** 官方下载包解压和自己手工写sysd启动脚本

** visa

直接 ip:9115 或者如下作ng proxy_pass

http://blackbox.com/metrics

http://blackbox.com/probe?target=prometheus.io&module=http_2xx

为1 成功 0 不成功 或者Logs 查看日志

* conf

这个可以参考 laradock 用变量哦
#填写你的 blackboxip,可能和我的不一样
 vim  prometheus/prometheus.yml

        #replacement: "10.3.10.124:9115"  # Blackbox exporter.
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.

重载
curl -X POST http://127.0.0.1:9090/-/reload

<http_probe>可配置参数 有空要看一下加强一下 

# 目标的HTTP基本身份验证凭据。
  basic_auth:
    [ username: <string> ]
    [ password: <secret> ]

* grafana

grafana 7587

9965号模板,数据源选择Prometheus 模板下载地址 https://grafana.com/grafana/dashboards/9965

可以直接进去容器里面安装 此模板需要安装饼状图插件 下载地址 https://grafana.com/grafana/plugins/grafana-piechart-panel 安装插件,重启grafana生效。

grafana-cli plugins install grafana-piechart-panel
service grafana-server restart

https://blog.csdn.net/shykevin/article/details/103527945

5345 好像有点老 https://grafana.com/grafana/dashboards/5345

* 实例了

** http post

https://market-api.126.com/api/v1/market/coin/rank/thirty


https://blog.csdn.net/qq_25934401/article/details/84325356


* 配置参考

 cp config.yml config.ymltodaygood
#add to config.yml
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - https://hk.search.yahoo.com
        #- https://pagertree.com
        #- https://prometheus.io
        labels:
          instance: user_status
          grop: 'web'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        #replacement: "localhost:9115"  # Blackbox exporter.
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
      - target_label: region
        replacement: "local"


  - job_name: 'blackbox http_post_2xx'
    metrics_path: /probe
    params:
      module: [http_post_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - https://m-api.126.com/api/v1/m/coin/rank/thirty
        #- https://linuxchina.net
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        #replacement: "localhost:9115"  # Blackbox exporter.
        #replacement: "10.3.10.124:9115"  # Blackbox exporter.
        replacement: "blackbox_exporter:9115"  # Blackbox exporter.
      - target_label: region
        replacement: "local"


官方配置eg 这个官方的放进去也是报错 老是重启 哈哈 https://github.com/prometheus/blackbox_exporter/blob/master/example.yml


blackbox exporter 配置文件解读

官方解释:https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md


git clone https://github.com/PagerTree/prometheus-grafana-alertmanager-example.git cd "$DIRECTORY"

* 进阶

网络探测:Blackbox Exporter

介绍几种应用场景 这个有空要试一下


blackbox_exporter源码阅读


网络探测监控的操作还有HTTPS DNS TCP ICMP SSH etc

监控主机存活状态

编辑prometheus配置文件


最后一行添加

最后一行添加

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

注意:10.165.94.31是被监控端ip,172.19.155.133是Blackbox_exporter

监控主机端口存活状态
  - job_name: 'prometheus_port_status'
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
      - targets: ['172.19.155.133:8765']
        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: 172.19.155.133:9115


监控网站状态

  - job_name: web_status
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets: ['http://www.baidu.com']
        labels:
          instance: user_status
          group: 'web'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: 172.19.155.133:9115


* see also

Blackbox exporter configuration

Blackbox exporter configuration Exmaple

https://github.com/prometheus/blackbox_exporter

https://yunlzheng.gitbook.io/prometheus-book/part-ii-prometheus-jin-jie/exporter/commonly-eporter-usage/install_blackbox_exporter

使用Prometheus的blackbox_exporter进行网络监控

Prometheus 监控之 Blackbox_exporter黑盒监测 [icmp、tcp、http(get\post)、dns、ssl证书过期时间]