51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Promethues如何针对站点、SSL监控

需求:使用监控插件名称: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/exporter
mv 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

访问:http://xxxx:9115/

制作system启动文件(可忽略)

[root@Prometheus exporter]#  cd /usr/lib/systemd/system
# 配置blackbox的开机自启文件
[root@Prometheus system]# cat blackbox_exporter.service 
[Unit]
Description=blackbox_exporter
After=network.target 
[Service]
User=prometheus
Group=prometheus
WorkingDirectory=/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地址

  • 方法一 、修改promethus-server的配置文件,添加blackbox_http_2xx (url直接写在文件中)
    /usr/local/prometheus/prometheus.yml

    • 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服务

展示最近监控信息

  • 方法二、修改promethus-server的配置文件,添加blackbox_http_2xx (url单独写一个规则文件)
    /usr/local/prometheus/prometheus.yml

    • 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

    URL规则文件 [root@node00 prometheus]# cat conf/blackbox-dis.yml

    • targets:
      • https://www.alibaba.com
      • https://www.tencent.com
      • https://www.baidu.com

重启动promethus服务

三、grafana展示blackbox采集数据

  • 1、 选择--》import-->通过导入9965,获取监控展示模板。

2、站点监控,域名监控、域名到期监控展示

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

解决方法

[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>

赞(0)
未经允许不得转载:工具盒子 » Promethues如何针对站点、SSL监控