centos操作系统上以service形式运行blackbox_exporter监控网页端口

文章目录


前言

记录一下centos操作系统上以简单的service形式运行blackbox_exporter监控网页端口的记录


一、blackbox_exporter是什么

Blackbox Exporter是Prometheus官方提供的黑盒监控解决方案之一。它允许用户通过HTTP、HTTPS、DNS、TCP、ICMP和gRPC等方式对网络端点进行探测,以检查服务的可用性、响应时间和性能等关键指标。

二、使用步骤

1.获取二进制文件

官网地址:

https://github.com/prometheus/blackbox_exporter/releases

https://prometheus.io/download/#memcached_exporter

我这里选择的是blackbox_exporter-0.25.0.linux-amd64.tar.gz版本

2.准备部署脚本

shell 复制代码
#!/bin/bash

set -e
tar -xvf ./blackbox_exporter-0.25.0.linux-amd64.tar.gz
if [ -d ./blackbox_exporter-0.25.0.linux-amd64/ ];then
  sudo cp ./blackbox_exporter-0.25.0.linux-amd64/blackbox_exporter /usr/local/bin/ && cp ./blackbox_exporter-0.25.0.linux-amd64/blackbox.yml /usr/local/bin/
else
  echo "请检查 blackbox_exporter 所在文件目录"
  exit 1
fi

sudo touch /usr/lib/systemd/system/blackbox_exporter.service
sudo chmod o+w /usr/lib/systemd/system/blackbox_exporter.service
sudo chmod o+x /usr/local/bin/blackbox_exporter

cat << EOF > /usr/lib/systemd/system/blackbox_exporter.service 
[Service]
User=$USER
Group=$USER
ExecStart=/usr/local/bin/blackbox_exporter --config.file=/usr/local/bin/blackbox.yml

[Install]
WantedBy=multi-user.target

[Unit]
Description=blackbox_exporter
After=network.target 
EOF

sudo systemctl daemon-reload
sudo systemctl start blackbox_exporter
sudo systemctl enable blackbox_exporter
sudo systemctl status blackbox_exporter
echo 'end success'

3.执行命令,进行部署

shell 复制代码
chmod +x blackbox-expoter-0.25.0.sh
./blackbox-expoter-0.25.0.sh

4.prometheus中增加需要监控页面的job信息

配置之后重启prometheus

yaml 复制代码
  - job_name: '150.2_web_port_status'
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
    - targets: ['192.168.150.2:8097']
      labels:
        instance: '192.168.150.2'
        tags: 'seafile平台端口'
    - targets: ['192.168.150.2:8098']
      labels:
        instance: '192.168.150.2'
        tags: 'onlyoffice平台端口'
    - targets: ['192.168.150.2:8088']
      labels:
        instance: '192.168.150.2'
        tags: '禅道平台端口'
    - targets: ['harbor.XXX.XXX.XX:10002']
      labels:
        instance: '192.168.150.2'
        tags: 'harbor平台端口'
    - targets: ['192.168.150.2:10001']
      labels:
        instance: '192.168.150.2'
        tags: 'gitlab平台端口'
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: 192.168.150.XX:9115

三、查看部署结果

Blackbox Exporter页面

prometheus界面

四、配置到grafana中

使用13659的dashboard

地址:https://grafana.com/grafana/dashboards/13659-blackbox-exporter-http-prober/

总结

简单记录一下,高阶功能有具体需求的时候再使用了。

相关推荐
qq_5895681019 分钟前
centos6.8镜像源yum install不成功,无法通过镜像源下载的解决方式
linux·运维·centos
不染尘.7 小时前
Linux的rpm与yum
linux·mysql·jdk·centos·tomcat·ssh
牛奶咖啡1312 小时前
Prometheus+Grafana构建云原生分布式监控系统(二)
prometheus·prometheus工作流程·prometheus适用场景·prometheus下载安装·prometheus指标解析·ntp时间同步操作·prometheus配置解析
lhyzws13 小时前
CENTOS上的网络安全工具(三十四) Portainer Kafka-Clickhouse部署(3) 连接kafka和clickhouse
clickhouse·kafka·centos
这儿有个昵称1 天前
互联网大厂Java面试场景:从Spring框架到微服务架构的提问解析
java·spring boot·微服务·kafka·grafana·prometheus·数据库优化
qq_589568101 天前
centos6.8版本虚拟机使用过程中的问题解决
数据结构·centos·list·esc键盘
weixin_462446232 天前
【原创实践】在 CentOS 上安装 JupyterHub 并配置 R 语言支持 Kernel
linux·r语言·centos
陕西小伙伴网络科技有限公司2 天前
CentOS-7 编译glibc-2.29
linux·运维·centos
米高梅狮子2 天前
02. 配置DNS服务器
运维·服务器·centos
赵民勇2 天前
yum命令用法与技巧总结
linux·centos