ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

blackbox_exporter安装

2022-09-01 00:00:09  阅读:205  来源: 互联网

标签:__ exporter blackbox target prometheus 安装 yml


本文主要介绍如何使用blackbox_exporter的收集被监控主机的网站状态、端口等信息,借助 Prometheus 最终以仪表盘的形式显示在 Grafana 中。
blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。
2.blackbox_exporter 应用场景
HTTP 测试
定义 Request Header 信息
判断 Http status / Http Respones Header / Http Body 内容
TCP 测试
业务组件端口状态监听
应用层协议定义与监听
ICMP 测试
主机探活机制
POST 测试
接口联通性
SSL 证书过期时间
3. 安装blackbox_exporter
3.1 各个版本的blackbox_exporter如下:
$ wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.15.1/blackbox_exporter-0.15.1.linux-amd64.tar.gz
$ tar -xvf blackbox_exporter-0.15.1.linux-amd64.tar.gz
$ mv blackbox_exporter-0.15.1.linux-amd64 /home/blackbox_exporter
3.3 创建systemd服务
vim /lib/systemd/system/blackbox_exporter.service
[Unit]
Description=blackbox_exporter
After=network.target
[Service]
ExecStart=/home/blackbox_exporter/blackbox_exporter --config.file=/home/blackbox_exporter/blackbox.yml
Restart=on-failure
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start blackbox_exporter
3.5 验证是否启动成功 默认监听端口为9115
$ systemctl status blackbox_exporter
$ netstat -lnpt|grep 9115
prometheus.yml中加入blackbox_exporter

[root@prometheus prometheus]# cat prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
- "rules/*.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["192.168.61.170:20015","192.168.61.171:20015"]
#监控tcp端口
- job_name: "port_status"
metrics_path: /probe
params:
module: [tcp_connect]
file_sd_configs:
- files:
- "/home/prometheus/file_sd/services.yml"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.61.169:9115
[root@prometheus prometheus]# cat file_sd/services.yml
- targets:
- 192.168.61.170:20015
- 192.168.61.171:22
- 172.20.3.85:9600
labels:
# group: catcher
tag: ssh
- targets:
- 192.168.61.170:22
labels:
# group: datahub
[root@prometheus prometheus]# cat rules/blackbox_network_stats.yml
groups:
- name: blackbox_network_stats
rules:
- alert: '服务探测失败'
expr: probe_success == 0
for: 60s
labels:
severity: high
alertinfo: push_blackbox_alert
annotations:
summary: "{{ $labels.instance }}探测失败"
description: "服务探测失败,请检查业务是否正常!!!"
1
2

标签:__,exporter,blackbox,target,prometheus,安装,yml
来源: https://www.cnblogs.com/xgsh/p/16645012.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有