Prometheus-2:blackbox_exporter黑盒监控
黑盒监控blackbox_exporter
部署及使用blackbox_exporter
部署blackbox_exporter
- 下载安装包
curl -LO https://github.com/prometheus/blackbox_exporter/releases/download/v0.22.0/blackbox_exporter-0.22.0.linux-amd64.tar.gz
- 展开程序包:
tar xf blackbox_exporter-0.22.0.linux-amd64.tar.gz -C /usr/local/
ln -sv /usr/local/blackbox_exporter-0.22.0.linux-amd64 /usr/local/blackbox_exporter
- 创建用户,或prometheus用户已经存在,可略过该步骤:
useradd -r prometheus
- 创建Systemd Unitfile,保存于/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
- 启动服务:
systemctl daemon-reload
systemctl start blackbox_exporter.service
systemctl enable blackbox_exporter.service
- 验证监听的端口,并测试访问其暴露的指标
ss -tnlp | grep '9115'
curl localhost:9115/metrics
icmp监控,监控主机存活状态
- job_name: "icmp_ping"
metrics_path: /probe
params:
module: [icmp] # 使用icmp模块
file_sd_configs:
- refresh_interval: 10s #检测时间间隔
files:
- "ping/ping_status*.yml" #具体的配置文件路径
relabel_configs:
- source_labels: [__address__]
regex: (.*)(:80)?
target_label: __param_target
replacement: ${1}
- source_labels: [__param_target]
target_label: instance
- source_labels: [__param_target]
regex: (.*)
target_label: ping
replacement: ${1}
- source_labels: []
regex: .*
target_label: __address__
replacement: 127.0.0.1:9115
这里有很多relabel的操作,下篇博客会详细讲解
cd /usr/local/prometheus/
mkdir ping
cd ping
- targets: ['monitor.example.com']
labels:
group: '跳板机'
- targets: ['10.xx.xx.xx','10.xx.xx.xx','10.xx.xx.xx']
labels:
group: 'k8s cluster'
- targets: ['www.baidu.com']
labels:
group: '百度'
./promtool check config prometheus.yml
curl -XPOST monitor.example.com:9090/-/reload

http监控
# Blackbox Exporter
- job_name: 'http_get_status'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
file_sd_configs:
- refresh_interval: 2m
files:
- "httpget/http_get*.yml" #具体的配置文件
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: "monitor.example.com:9115" # 指向实际的Blackbox exporter.
- target_label: region
replacement: "local"
static_configs:
- targets:
- "https://monitor.example.com"
- "http://monitor.example.com:8080"
- "www.google.com"
refresh_interval: 2m
curl -XPOST monitor.example.com:9090/-/reload


tcp端口监控
- job_name: 'tcp_port_status'
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: ['monitor.example.com:80','monitor.example.com:8080','monitor.example.com:443']
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: monitor.example.com:9115

自定义blackbox.yml
# github地址
https://github.com/prometheus/blackbox_exporter # github中blackbox.yml各配置项解析
blackbox_exporter/CONFIGURATION.md at master · prometheus/blackbox_exporter · GitHub # github中example文件
blackbox_exporter/example.yml at master · prometheus/blackbox_exporter · GitHub
modules:
http_2xx:
prober: http
http:
preferred_ip_protocol: "ip4"
valid_http_versions: ["HTTP/1.1", "HTTP/2"]
valid_status_codes: [200,301,302,303]
tls_config:
insecure_skip_verify: true
http_ca_example:
prober: http
http:
method: GET
preferred_ip_protocol: "ip4"
valid_http_versions: ["HTTP/1.1", "HTTP/2"]
fail_if_ssl: false
fail_if_not_ssl: true
tls_config:
insecure_skip_verify: false
ca_file: /usr/local/blackbox_exporter/certs/ca.crt
cert_file: /usr/local/blackbox_exporter/certs/server.crt
key_file: /usr/local/blackbox_exporter/certs/server.key
systemctl restart blackbox_exporter.service
- job_name: 'http_get_status'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
file_sd_configs:
- refresh_interval: 2m
files:
- "httpget/http_get*.yml" #具体的配置文件
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: "monitor.example.com:9115" # 指向实际的Blackbox exporter.
- target_label: region
replacement: "local" - job_name: 'http_get_ca_status'
metrics_path: /probe
params:
module: [http_ca_example]
file_sd_configs:
- refresh_interval: 2m
files:
- "httpget/http_ca.yml"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: "monitor.example.com:9115" # 指向实际的Blackbox exporter.
- target_label: region
replacement: "beijing"
curl -XPOST monitor.example.com:9090/-/reload
probe_http_duration_seconds{phase="tls"}


Prometheus-2:blackbox_exporter黑盒监控的更多相关文章
- Prometheus 监控之 Blackbox_exporter黑盒监测
Prometheus 监控之 Blackbox_exporter黑盒监测 1.blackbox_exporter概述 1.1 Blackbox_exporter 应用场景 2.blackbox_exp ...
- prometheus 配置容器 cadvisor监控节点
安装cadvisor docker run \ --volume=/:/roofs:ro \ --volume=/var/run:/var/run:rw \ --volume=/sys:/sys:ro ...
- 理解OpenShift(7):基于 Prometheus 的集群监控
理解OpenShift(1):网络之 Router 和 Route 理解OpenShift(2):网络之 DNS(域名服务) 理解OpenShift(3):网络之 SDN 理解OpenShift(4) ...
- prometheus + grafana部署RabbitMQ监控
prometheus + grafana部署RabbitMQ监控 1.grafana导入dashboards https://grafana.com/dashboards/2121 2.expor ...
- 基于Prometheus和Grafana的监控平台 - 运维告警
通过前面几篇文章我们搭建好了监控环境并且监控了服务器.数据库.应用,运维人员可以实时了解当前被监控对象的运行情况,但是他们不可能时时坐在电脑边上盯着DashBoard,这就需要一个告警功能,当服务器或 ...
- Centos7.X 搭建Prometheus+node_exporter+Grafana实时监控平台
Prometheus简介 什么是 Prometheus Prometheus是一个开源监控报警系统和时序列数据库 主要功能 多维数据模型(时序由 metric 名字和 k/v 的 labels 构成) ...
- Prometheus+Grafana通过kafka_exporter监控kafka
Prometheus+Grafana通过kafka_exporter监控kafka 一.暴露 kafka-metric 方式 二.jmx_exporter方式 2.1 下载jmx_prometheus ...
- Docker监控平台prometheus和grafana,监控redis,mysql,docker,服务器信息
Docker监控平台prometheus和grafana,监控redis,mysql,docker,服务器信息 一.通过redis_exporter监控redis 1.1 下载镜像 1.2 运行服务 ...
- Grafana+Prometheus 搭建 JuiceFS 可视化监控系统
作为承载海量数据存储的分布式文件系统,用户通常需要直观地了解整个系统的容量.文件数量.CPU 负载.磁盘 IO.缓存等指标的变化. JuiceFS 没有重复造轮子,而是通过 Prometheus 兼容 ...
- 【Prometheus+Grafana系列】监控MySQL服务
前言 前面的一篇文章已经介绍了 docker-compose 搭建 Prometheus + Grafana 服务.当时实现了监控服务器指标数据,是通过 node_exporter.Prometheu ...
随机推荐
- CI框架内置分页代码
Controller 控制器代码 <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Welc ...
- 谈一谈Python中的装饰器
1.装饰器基础介绍 1.1 何为Python中的装饰器? Python中装饰器的定义以及用途: 装饰器是一种特殊的函数,它可以接受一个函数作为参数,并返回一个新的函数.装饰器可以用来修改或增强函数的行 ...
- java 实现逻辑分页
//逻辑分页PageModel model = new PageModel();long total = list.size();model.setTotal(total);model.setPage ...
- 2023-05-02:如果一个正整数每一个数位都是 互不相同 的,我们称它是 特殊整数 。 给你一个正整数 n ,请你返回区间 [1, n] 之间特殊整数的数目。 输入:n = 20。 输出:19。
2023-05-02:如果一个正整数每一个数位都是 互不相同 的,我们称它是 特殊整数 . 给你一个正整数 n ,请你返回区间 [1, n] 之间特殊整数的数目. 输入:n = 20. 输出:19. ...
- 关于java中的super
首当其冲先说一下super的用途和含义.他是用于调用一些被重写的方法. 这里还可以复习一下子这个重写:重写是把新的方法放在被重写的方法前面.在被重写的子类中,优先调用重写后的方法.但是如果想要调用原本 ...
- 自定义alert、confirm、prompt的vue组件
Prompt.vue组件 说明: 通过props定制定制的Prompt,可选值 mode 默认值:prompt, 其他模式:confirm.message(简单的提示,可设置提示显示时间,类似aler ...
- Maven工程开发
Maven工程开发 编写pom.xml配置文件 <properties></properties>定义项目的基本信息 groupId 反向域名,定义项目组名 artifactI ...
- selenium文件上传和弹框处理
文件上传 input 标签可以直接使用send_keys(文件地址)上传文件 用法: el = driver.find_element_by_id('上传按钮id') el.send_keys(&qu ...
- 2022-04-20:小团去参加军训,军训快要结束了, 长官想要把大家一排n个人分成m组,然后让每组分别去参加阅兵仪式, 只能选择相邻的人一组,不能随意改变队伍中人的位置, 阅兵仪式上会进行打分,其中
2022-04-20:小团去参加军训,军训快要结束了, 长官想要把大家一排n个人分成m组,然后让每组分别去参加阅兵仪式, 只能选择相邻的人一组,不能随意改变队伍中人的位置, 阅兵仪式上会进行打分,其中 ...
- 数据分析缺失值处理(Missing Values)——删除法、填充法、插值法
缺失值指数据集中某些变量的值有缺少的情况,缺失值也被称为NA(not available)值.在pandas里使用浮点值NaN(Not a Number)表示浮点数和非浮点数中的缺失值,用NaT表示时 ...