如果你需要监控两个主机、主机与外部服务之间的网络状况,那么就可以试一试本文提到的 Blackbox Exporter。
1. 安装 Blackbox
1.1 在主机上部署
1
2
3
4
5
|
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.21.0/blackbox_exporter-0.21.0.linux-amd64.tar.gz
tar -xzvf blackbox_exporter-0.21.0.linux-amd64.tar.gz
mv blackbox_exporter-0.21.0.linux-amd64/blackbox_exporter /usr/bin/
mkdir /etc/prometheus
mv blackbox_exporter-0.21.0.linux-amd64/blackbox.yml /etc/prometheus/
|
1
|
rm -rf blackbox_exporter-0.21.0.linux-amd64*
|
1
|
vim /usr/lib/systemd/system/blackbox_exporter.service
|
2. 测试主机对外访问连通性
blackbox_exporter
默认在本地 9115 端口暴露服务。实际上,通过拼接 URL 的方式,我们就可以实现主机对任意服务的连通测试,下面是一个实例,只需要提供 target、module 参数即可,其中 target 表示测试的目标,module 表示测试用的模块:浏览器访问 http://BLACKBOX_HOST_IP:9115/probe?target=google.com&module=http_2xx,需要将 BLACKBOX_HOST_IP
替换为主机 IP。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds
1. TYPE probe_dns_lookup_time_seconds gauge
probe_dns_lookup_time_seconds 0.030818323
1. HELP probe_duration_seconds Returns how long the probe took to complete in seconds
1. TYPE probe_duration_seconds gauge
probe_duration_seconds 0.353982702
1. HELP probe_failed_due_to_regex Indicates if probe failed due to regex
1. TYPE probe_failed_due_to_regex gauge
probe_failed_due_to_regex 0
1. HELP probe_http_content_length Length of http content response
1. TYPE probe_http_content_length gauge
probe_http_content_length -1
1. HELP probe_http_duration_seconds Duration of http request by phase, summed over all redirects
1. TYPE probe_http_duration_seconds gauge
probe_http_duration_seconds{phase="connect"} 0.08580119300000001
probe_http_duration_seconds{phase="processing"} 0.201979714
probe_http_duration_seconds{phase="resolve"} 0.060847821999999996
probe_http_duration_seconds{phase="tls"} 0
probe_http_duration_seconds{phase="transfer"} 0.003931112
1. HELP probe_http_redirects The number of redirects
1. TYPE probe_http_redirects gauge
probe_http_redirects 3
1. HELP probe_http_ssl Indicates if SSL was used for the final redirect
1. TYPE probe_http_ssl gauge
probe_http_ssl 0
1. HELP probe_http_status_code Response HTTP status code
1. TYPE probe_http_status_code gauge
probe_http_status_code 200
1. HELP probe_http_uncompressed_body_length Length of uncompressed response body
1. TYPE probe_http_uncompressed_body_length gauge
probe_http_uncompressed_body_length 13645
1. HELP probe_http_version Returns the version of HTTP of the probe response
1. TYPE probe_http_version gauge
probe_http_version 1.1
1. HELP probe_ip_addr_hash Specifies the hash of IP address. It's useful to detect if the IP address changes.
1. TYPE probe_ip_addr_hash gauge
probe_ip_addr_hash 4.032438981e+09
1. HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6
1. TYPE probe_ip_protocol gauge
probe_ip_protocol 4
1. HELP probe_success Displays whether or not the probe was a success
1. TYPE probe_success gauge
probe_success 1
|
scrape_configs:
- job_name: 'blackbox_http'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: ['github.com']
labels:
url: 'github.com'
- targets: ['dl-cdn.alpinelinux.org']
labels:
url: 'dl-cdn.alpinelinux.org'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: BLACKBOX_HOST_IP:9115
- job_name: 'blackbox_icmp'
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets: ['github.com']
labels:
url: 'github.com'
- targets: ['dl-cdn.alpinelinux.org']
labels:
url: 'dl-cdn.alpinelinux.org'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: BLACKBOX_HOST_IP:9115
|
modules:
http_2xx:
prober: http
http:
preferred_ip_protocol: "ipv4"
|
systemctl restart blackbox_exporter
|
grafana-cli plugins install grafana-piechart-panel
|
systemctl restart grafana-server
|
相关推荐
开宗明义,本篇带来:深度学习的入门框架 —— TensorFlow,以及将其在 Amazon Deep Learning AMI 中私有化部署。 引言 怎么理解深度学习?举个比较直白的例子,我们作为程序员写一段算法用来实现数学中的排序问题可能比较轻松,如果现在要写一段代码来判断一张图片的动物是猫还是狗,那我相信会难倒绝大部分的 CRUD 程序员。 不过这也没啥毛病,毕竟术业有专攻!深度学习可以很方
更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群 近日,火山引擎数智平台VeDI与DataFun联合举办以“OLAP计算引擎”为主题的直播活动,来自火山引擎数智平台VeDI的产品专家从技术选型、能力分析、性能优化以及应用场景落地多个角度,介绍火山引擎ByteHouse如何基于ClickHouse实现实时计算能力升级。 据介绍,火山引擎ByteHouse来源于字节
在某些生产环境下,我们仅需要一个原生的 K8s 集群,无需部署 KubeSphere 这样的图形化管理控制台。在我们已有的技术栈里,已经习惯了利用 KubeKey 部署 KubeSphere 和 K8s 集群。今天,我将为大家实战演示如何在 openEuler 22.03 LTS SP3 上,利用 KubeKey 部署一套纯粹的 K8s 集群。 实战服务器配置 (架构 1:1 复刻小规模生产环境,
Jenkins只是一个平台,真正运作的都是插件。这就是jenkins流行的原因,因为jenkins什么插件都有。Hudson是Jenkins的前身,是基于Java开发的一种持续集成工具,用于监控程序重复的工作,Hudson后来被收购,成为商业版。后来创始人又写了一个jenkins,jenkins在功能上远远超过hudson Jenkins+Maven+SVN+Nexus 搭建持续集成环境 Jenk
- Restful 请求 1 curl -X POST --data 'keyword=value' http://domain.com/mypath/ -X 后面还可以是 DELETE PUT 等。2. 添加头部 1 curl -H 'Content-Type:application/json' -H 'Authorization: beare
回到顶部