Prometheus(六)黑盒监控

2024-06-07 18:38
文章标签 监控 prometheus 黑盒

本文主要是介绍Prometheus(六)黑盒监控,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

黑盒监控(blackbox_exporter)
之前介绍的对exporter的使用可以称为“白盒监控”,既需要把对应的exporter程序安装到被监控的目标主机上,从而实现对主机资源及其状态的数据采集工作。
黑盒监控,blackbox_exporter无须安装在被监控的目标环境中,用户只需要将其安装在于promethenus和被监控目标互通的环境中,通过HTTP、HTTPS、DNS、TCP、ICMP等方式对网络进行探测监控,还可以探测SSL证书过期时间
blackbox_exporter下载地址:https://prometheus.io/download/

1)安装blackbox_exporter
#上传软件

[root@localhost opt] ll blackbox_exporter-0.16.0.linux-amd64.tar.gz 
-rw-r--r--. 1 root root 8314959 May 18 20:40 blackbox_exporter-0.16.0.linux-amd64.tar.gz
[root@localhost opt] tar -zxvf blackbox_exporter-0.16.0.linux-amd64.tar.gz 
[root@localhost opt] cp -r blackbox_exporter-0.16.0.linux-amd64 /usr/local/blackbox_exporter

2)添加blackbox_exporter为系统服务开机启动配置文件blackbox_exporter.service

[root@localhost ~] vi /usr/lib/systemd/system/blackbox_exporter.service
[Unit]
Description=blackbox_exporter
After=network.target[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/blackbox_exporter/blackbox_exporter \--config.file=/usr/local/blackbox_exporter/blackbox.yml \--web.listen-address=:9115
Restart=on-failure[Install]
WantedBy=multi-user.target
[root@localhost ~] systemctl daemon-reload
[root@localhost ~] systemctl restart blackbox_exporter
[root@localhost ~] netstat -tlunp | grep blackbox_expo
tcp6       0      0 :::9115              :::*              LISTEN      11925/blackbox_expo

web浏览
在这里插入图片描述
icmp监控,监控主机存活状态
通过icmp 这个指标的采集,我们可以确认到对方的线路是否有问题。这个也是监控里面比较重要的一个环节。我们要了解全国各地到我们机房的线路有哪条有问题我们总结了两种方案:
全国各地各节点ping 和访问数据采集。这种类似听云运营商有提供这类服务,但是要花钱;
我现在用的方法就是:找各地测试ping 的节点,我们从机房主动ping 看是否到哪个线路有故障,下面我们开始。

prometheus 添加相关监控,Blackbox 使用默认配置启动即可

[root@localhost ~] vi /usr/local/prometheus/prometheus.yml
 - job_name: "icmp_ping"metrics_path: /probeparams:module: [icmp]  # 使用icmp模块file_sd_configs:- refresh_interval: 10sfiles:- "ping/ping_status*.yml"  #具体的配置文件relabel_configs:- source_labels: [__address__]regex: (.*)(:80)?target_label: __param_targetreplacement: ${1}- source_labels: [__param_target]target_label: instance- source_labels: [__param_target]regex: (.*)target_label: pingreplacement: ${1}- source_labels: []regex: .*target_label: __address__replacement: 127.0.0.1:9115

针对上面的配置文件(- “ping/ping_status*.yml” )创建相关的过滤配置

[root@prometheus rj] cd /usr/local/prometheus/
[root@localhost prometheus] mkdir ping
[root@localhost prometheus] vi ping_status.yml 
- targets: ['220.181.38.150','14.215.177.39','180.101.49.12','14.215.177.39','180.101.49.11','14.215.177.38','14.215.177.38']labels:group: '一线城市-电信网络监控'
- targets: ['112.80.248.75','163.177.151.109','61.135.169.125','163.177.151.110','180.101.49.11','61.135.169.121','180.101.49.11']labels:group: '一线城市-联通网络监控'
- targets: ['183.232.231.172','36.152.44.95','182.61.200.6','36.152.44.96','220.181.38.149']labels:group: '一线城市-移动网络监控' 
[root@prometheus ping] systemctl restart prometheus

在这里插入图片描述

以下是其他的几种监控状态如下
监控主机端口存活状态

[root@localhost ~] vi /usr/local/prometheus/prometheus.yml
- job_name: 'prometheus_port_status'metrics_path: /probeparams: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

监控网站状态
prometheus 添加相关监控,Blackbox 使用默认配置启动即可

[root@localhost ~]# cat /usr/local/prometheus/prometheus.yml
  - job_name: "blackbox"metrics_path: /probeparams:module: [http_2xx]  #使用http模块file_sd_configs: - refresh_interval: 1mfiles: - "/qq/blackbox*.yml"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
[root@localhost ~]# cat /qq/blackbox-dis.yml 
- targets:- https://www.zhibo8.cc- https://www.baidu.com

这篇关于Prometheus(六)黑盒监控的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1039984

相关文章

SpringBoot监控API请求耗时的6中解决解决方案

《SpringBoot监控API请求耗时的6中解决解决方案》本文介绍SpringBoot中记录API请求耗时的6种方案,包括手动埋点、AOP切面、拦截器、Filter、事件监听、Micrometer+... 目录1. 简介2.实战案例2.1 手动记录2.2 自定义AOP记录2.3 拦截器技术2.4 使用Fi

Spring Boot Actuator应用监控与管理的详细步骤

《SpringBootActuator应用监控与管理的详细步骤》SpringBootActuator是SpringBoot的监控工具,提供健康检查、性能指标、日志管理等核心功能,支持自定义和扩展端... 目录一、 Spring Boot Actuator 概述二、 集成 Spring Boot Actuat

一文解密Python进行监控进程的黑科技

《一文解密Python进行监控进程的黑科技》在计算机系统管理和应用性能优化中,监控进程的CPU、内存和IO使用率是非常重要的任务,下面我们就来讲讲如何Python写一个简单使用的监控进程的工具吧... 目录准备工作监控CPU使用率监控内存使用率监控IO使用率小工具代码整合在计算机系统管理和应用性能优化中,监

Zabbix在MySQL性能监控方面的运用及最佳实践记录

《Zabbix在MySQL性能监控方面的运用及最佳实践记录》Zabbix通过自定义脚本和内置模板监控MySQL核心指标(连接、查询、资源、复制),支持自动发现多实例及告警通知,结合可视化仪表盘,可有效... 目录一、核心监控指标及配置1. 关键监控指标示例2. 配置方法二、自动发现与多实例管理1. 实践步骤

prometheus如何使用pushgateway监控网路丢包

《prometheus如何使用pushgateway监控网路丢包》:本文主要介绍prometheus如何使用pushgateway监控网路丢包问题,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录监控网路丢包脚本数据图表总结监控网路丢包脚本[root@gtcq-gt-monitor-prome

Spring Boot集成Druid实现数据源管理与监控的详细步骤

《SpringBoot集成Druid实现数据源管理与监控的详细步骤》本文介绍如何在SpringBoot项目中集成Druid数据库连接池,包括环境搭建、Maven依赖配置、SpringBoot配置文件... 目录1. 引言1.1 环境准备1.2 Druid介绍2. 配置Druid连接池3. 查看Druid监控

如何在Ubuntu 24.04上部署Zabbix 7.0对服务器进行监控

《如何在Ubuntu24.04上部署Zabbix7.0对服务器进行监控》在Ubuntu24.04上部署Zabbix7.0监控阿里云ECS服务器,需配置MariaDB数据库、开放10050/1005... 目录软硬件信息部署步骤步骤 1:安装并配置mariadb步骤 2:安装Zabbix 7.0 Server

JVisualVM之Java性能监控与调优利器详解

《JVisualVM之Java性能监控与调优利器详解》本文将详细介绍JVisualVM的使用方法,并结合实际案例展示如何利用它进行性能调优,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录1. JVisualVM简介2. JVisualVM的安装与启动2.1 启动JVisualVM2

使用Python实现实时金价监控并自动提醒功能

《使用Python实现实时金价监控并自动提醒功能》在日常投资中,很多朋友喜欢在一些平台买点黄金,低买高卖赚点小差价,但黄金价格实时波动频繁,总是盯着手机太累了,于是我用Python写了一个实时金价监控... 目录工具能干啥?手把手教你用1、先装好这些"食材"2、代码实现讲解1. 用户输入参数2. 设置无头浏

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展