如果你需要监控两个主机、主机与外部服务之间的网络状况,那么就可以试一试本文提到的 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
|
相关推荐
本文根据腾讯云赵化冰和知乎唐阳在 IstioCon 2021 中的演讲 “How to Manage Any Layer-7 Traffic in an Istio Service Mesh?” 整理而成。 大家好,今天我们想和大家分享的主题是如何扩展 Istio 以支持任何七层协议?作为云原生领域中一个人气非常高的开源项目, Istio 目前已经基本成为了 Service Mesh 的事实标准。
简介 本文是基于阿里云托管服务网格 ASM 完成应用在多集群环境中全自动化渐进式发布的 GitOps 实践。 ASM 阿里云服务网格(Alibaba Cloud Service Mesh,简称 ASM)提供了一个全托管式的服务网格平台,兼容于社区 Istio 开源服务网格,用于简化服务的治理,包括服务调用之间的流量路由与拆分管理、服务间通信的认证安全以及网格可观测性能力,从而极大地减轻开发与运维的
本文为翻译文章,点击查看原文。 编者按 作者简要介绍了熔断的概念,然后以实战演练的方式分别演示了如何通过Backyards UI、CLI等方式创建并设置熔断功能。注:Backyards是Banzai Cloud开发的一款基于Istio的服务网格产品,本文是该产品功能介绍系列中的一篇。 前言 Istio因灵活的可观察性和安全的服务间通信受到了赞许。然而,其他更重要的功能才真正使得Istio成为了服务
前言: 考虑到公司持续集成与docker容器技术实施已有一段时间,取得了不错的效果,但对于设备运维、系统隔离、设备利用率和扩展性还有待提升,综合目前比较成熟的微服务技术,打算把现有业务迁移到K8S集群。 由于公司所有业务均部署在阿里云上,最开始就调研了阿里云自己提供的Kubernetes集群,但后来还是放弃了,主要考虑几方面: 阿里云K8S集群尚不成熟,使用的版本也相对较老,不能及时更新版本 阿里
作者:极氪汽车吴超 前言 2021 年,极氪 001 迅速崭露头角,仅用 110 天便创下了首款车型交付量“最快破万”的纪录。2022 年 11 月,极氪 009 在短短 76 天内便率先完成了首批交付,刷新了中国豪华纯电品牌交付速度的纪录。2023 年 6 月,极氪汽车再次交付 10620 辆,成为保持五个月连续同比增长的唯一豪华纯电品牌。至此,极氪 001 已成为全球最快突破 10 万辆销售的
回到顶部