<返回更多

Promethues如何针对站点、SSL监控

2020-07-01    
加入收藏

需求:使用监控插件名称:bloackbox exporter

bloackbox exporter 是prometheus社区提供的黑盒监控解决方案,运行用户通过HTTP、HTTPS、DNS、TCP以及ICMP的方式对网络进行探测(主动监测主机与服务状态)。

一、下载安装包部署

wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.16.0/blackbox_exporter-0.16.0.linux-amd64.tar.gz
tar zxvf blackbox_exporter-0.16.0.linux-amd64.tar.gz
mkdir /usr/local/exportermv blackbox_exporter-0.16.0.linux-amd64 /usr/local/exporter/blackbox_exporter
/usr/local/exporter/blackbox_exporter/blackbox_exporter  --config.file=/usr/local/exporter/blackbox_exporter/blackbox.yml

配置文件

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

 

Promethues如何针对站点、SSL监控

 

 

[root@Prometheus exporter]#  cd /usr/lib/systemd/system
# 配置blackbox的开机自启文件[root@Prometheus system]# cat blackbox_exporter.service 
[Unit]Description=blackbox_exporterAfter=network.target [Service]User=prometheusGroup=prometheusWorkingDirectory=/usr/local/exporter/blackbox_exporter
ExecStart=/usr/local/exporter/blackbox_exporter/blackbox_exporter
[Install]WantedBy=multi-user.target# 启动[root@node00 system]# systemctl restart blackbox_exporter
# 查看状态[root@node00 system]# systemctl status blackbox_exporter
# 开机自启[root@node00 system]# systemctl enable blackbox_exporter
```

二、配置promethus采集数据,修改promethus-server配置文件,监控URL地址

 - job_name: 'blackbox_http_2xx'
    scrape_interval: 45s
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    static_configs:
        - targets:
          - https://www.baidu.com/
          - 172.0.0.1:9090
          - https://www.qq.com
    relabel_configs:
        - source_labels: [__address__]
          target_label: __param_target
        - source_labels: [__param_target]
          target_label: instance
        - target_label: __address__
          replacement: 114.67.116.119:9115 

重启动promethus服务

展示最近监控信息

Promethues如何针对站点、SSL监控

 

 

- job_name: "blackbox_http_file_test"
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    file_sd_configs: 
    - refresh_interval: 1m
      files: 
      - "/usr/local/prometheus/conf/blackbox*.yml"
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: 114.67.116.119:9115 
[root@node00 prometheus]# cat conf/blackbox-dis.yml 
- targets:
  - https://www.alibaba.com
  - https://www.tencent.com
  - https://www.baidu.com 

重启动promethus服务

三、grafana展示blackbox采集数据

 

Promethues如何针对站点、SSL监控

 

 

Promethues如何针对站点、SSL监控

 

 

Promethues如何针对站点、SSL监控

 

 

四、错误提示 Panel plugin not found: grafana-piechart-panel

Promethues如何针对站点、SSL监控

 

解决方法

[root@Prometheus ~]# grafana-cli plugins install grafana-piechart-panel
installing grafana-piechart-panel @ 1.4.0
from: https://grafana.com/api/plugins/grafana-piechart-panel/versions/1.4.0/download
into: /var/lib/grafana/plugins
✔ Installed grafana-piechart-panel successfully Restart grafana after installing plugins . <service grafana-server restart>
声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>