惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security Affairs
N
News and Events Feed by Topic
T
Tenable Blog
P
Proofpoint News Feed
W
WeLiveSecurity
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
Help Net Security
Help Net Security
I
Intezer
T
Threat Research - Cisco Blogs
S
Secure Thoughts
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
Google Online Security Blog
Google Online Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
The Hacker News
The Hacker News
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tor Project blog
N
News | PayPal Newsroom
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
Arctic Wolf
Forbes - Security
Forbes - Security
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Latest
Security Latest
P
Palo Alto Networks Blog
S
Schneier on Security
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
H
Heimdal Security Blog
V
Vulnerabilities – Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园_首页
T
Troy Hunt's Blog
Latest news
Latest news
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
L
LINUX DO - 热门话题
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
V
Visual Studio Blog
H
Hacker News: Front Page

杂烩饭

使用 RustFS 自建对象存储 使用cURL命令管理对象存储(s3) AGENTS.md Prometheus使用kubeconfig做k8s的service 自动发现监控 定制Windows系统镜像iso 使用create-dmg工具制作dmg安装包 使用create-dmg工具制作dmg安装包 - 技术栈 superpowers Nexus仓库搭建记录 Git Merge代码冲突的解决方式 在 Linux 系统中安装与配置 OpenVPN:从入门到精通 使用 Easytier-web 管理 easytier 节点 ingress-nginx 去除指定context path 在macOS上使用MusicPlayer2听本地音乐 Kubernetes 1.34 + RHEL10 + Cilium + kube-vip 高可用集群部署 使用腾讯云CLS收集TKE(k8s)业务日志 容器调试工具之BusyBox 无Docker环境进行容器镜像操作 使用kubeadm部署一套高可用k8s集群1.34 for Ubuntu 正在运行的Docker容器增加端口映射 轻量级组网工具WireGuard 在Kubernetes中部署一个单节点Elasticsearch 使用openssl制作自签名双向认证(mTLS)证书 minio自建对象存储 ingress-nginx 使用自定义的nginx配置 P12格式证书与PEM格式转换 记一次MySQL字符集转换导致的故障 使用双向认证增加git仓库安全性 Prometheus自动监控K8S集群中的service Grafana 查询SQL 自定义变量 使用selenium来实现Grafana的自动截图
使用blackbox-exporter做域名监控
张理坤 · 2025-06-17 · via 杂烩饭

对应的 blackbox exporter 的配置文件:

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
modules:
http_2xx:
prober: http
timeout: 5s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2"]
valid_status_codes: [200]
method: GET
preferred_ip_protocol: "ip4"
http_post_2xx:
prober: http
timeout: 5s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2"]
method: POST
preferred_ip_protocol: "ip4"
tcp_connect:
prober: tcp
timeout: 2s
icmp:
prober: icmp
timeout: 2s
icmp:
preferred_ip_protocol: "ip4"
http_accept_404:
prober: http
timeout: 10s
http:
valid_status_codes: [200, 201, 204, 404]
method: GET
preferred_ip_protocol: "ip4"
no_follow_redirects: false

其中:

  • http_2xx: get 请求 200 认为是正常的
  • http_post_2xx: post 请求 200 认为是正常的
  • tcp_connect: 测试端口是不是通的
  • icmp:能否 ping 通
  • http_accept_404: get 请求,404 也认为是正常的

配置 Prometheus

HTTP 监控 只有 200 是正常请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- job_name: 'http_get'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: ['https://test.com']
labels:
app: 生产环境域名
- targets: ['http://1.1.1.1:8888']
labels:
app: 测试IP地址
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: blackbox-exporter.monitor.svc:9115
- source_labels: [__param_target]
target_label: instance

HTTP 监控 2xx 和 404 都认为是正常请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- job_name: 'http_get_with_404'
metrics_path: /probe
params:
module: [http_accept_404]
static_configs:
- targets: ['https://test.com']
labels:
app: 生产环境域名
- targets: ['http://1.1.1.1:8888']
labels:
app: 测试IP地址
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: blackbox-exporter.monitor.svc:9115
- source_labels: [__param_target]
target_label: instance

TCP 端口监控

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
- job_name: port
honor_timestamps: true
params:
module:
- tcp_connect
scrape_interval: 10s
scrape_timeout: 10s
metrics_path: /probe
scheme: http
follow_redirects: true
static_configs:
- targets: ['1.1.1.1:8662']
labels:
app: 密码机-1
- targets: ['2.2.2.2:8662']
labels:
app: 密码机-2
relabel_configs:
- source_labels: [__address__]
separator: ;
regex: (.*)
target_label: __param_target
replacement: $1
action: replace
- source_labels: [__param_target]
separator: ;
regex: (.*)
target_label: addr
replacement: $1
action: replace
- source_labels: [__param_target]
separator: ;
regex: (.+):(.*)
target_label: port
replacement: $2
action: replace
- separator: ;
regex: (.*)
target_label: __address__
replacement: blackbox-exporter:9115
action: replace

验证

1
curl "http://blackbox-exporter.monitor:9115/probe?target=http://a.test.com&module=http_accept_404"

PromQL 常用查询

1
2
3
4
5
6
7
8

(probe_ssl_earliest_cert_expiry{project="project1",env="prod"} - time()) / 60 / 60 / 24


probe_success{project="project1",env="prod"}


probe_duration_seconds{project="project1",env="prod"}

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 杂烩饭