语句
count by (__name__)({__name__=~"probe_.*"})

指标解析
| 指标 | 含义 |
|---|
| probe_dns_lookup_time_seconds | DNS解析时间(秒) |
| probe_duration_seconds | 探测总耗时(秒) |
| probe_failed_due_to_regex | 由于正则表达式匹配失败的探测数量 |
| probe_http_content_length | HTTP响应内容长度(字节) |
| probe_http_duration_seconds | HTTP请求耗时(秒) |
| probe_http_last_modified_timestamp_seconds | HTTP响应的"Last-Modified"时间戳(秒) |
| probe_http_redirects | HTTP重定向次数 |
| probe_http_ssl | HTTP是否使用SSL/TLS加密 |
| probe_http_status_code | HTTP响应状态码 |
| probe_http_uncompressed_body_length | HTTP响应未压缩的内容长度(字节) |
| probe_http_version | HTTP协议版本 |
| probe_ip_addr_hash | 探测目标IP地址的哈希值 |
| probe_ip_protocol | 探测目标IP地址的协议 |
| probe_success | 探测是否成功,值为0表示失败,1表示成功 |
告警语句
groups:
- name: blackbox_exporter_alert_rules
rules:
- alert: DnsLookupSlowAlert
expr: probe_dns_lookup_time_seconds > 1
for: 5m
labels:
severity: warning
annotations:
summary: "DNS解析过慢"
description: "DNS解析时间超过1秒 当前dns解析时间为: {{ $value }}"
- alert: HttpServerErrorAlert
expr: probe_http_status_code!=200
for: 3m
labels:
severity: critical
annotations:
summary: "HTTP响应状态码非200"
description: "HTTP响应状态码非200 当前值为: {{ $value }}"
- alert: ProbeTimeoutAlert
expr: probe_duration_seconds > 30
for: 2m
labels:
severity: warning
annotations:
summary: "探测超时告警"
description: "对目标的探测耗时超过30秒 当前探测时间为: {{ $value }}秒"
- alert: TooManyRedirectsAlert
expr: probe_http_redirects > 5
for: 5m
labels:
severity: warning
annotations:
summary: "HTTP重定向过多"
description: "HTTP重定向过多 当前重定向次数为: {{ $value }}"
- alert: HttpContentLengthTooLargeAlert
expr: probe_http_content_length > 1048576
for: 10m
labels:
severity: warning
annotations:
summary: "HTTP响应内容过大告警"
description: "目标的HTTP响应内容长度超过1 MB 当前值为: {{ $value }}"
- alert: HttpVersionMismatchAlert
expr: probe_http_version != 1.1
for: 5m
labels:
severity: warning
annotations:
summary: "HTTP协议版本不匹配告警"
description: "目标服务器不使用HTTP/1.1版本 当前值为: {{ $value }}"
- alert: SslCertificateExpiryAlert
expr: probe_http_ssl == 1 and probe_http_ssl_cert_expiry < 604800
for: 1h
labels:
severity: critical
annotations:
summary: "SSL证书到期警告"
description: "SSL证书将在一周内过期,请尽快更换证书"
- alert: HttpContentLengthMissingAlert
expr: probe_failed_due_to_regex{probe="http"} == 1
for: 5m
labels:
severity: warning
annotations:
summary: "缺少HTTP内容长度告警"
description: "HTTP探测失败,可能由于缺少HTTP响应内容长度。"
- alert: ProbeSuccessFailureAlert
expr: probe_success == 0
for: 5m
labels:
severity: critical
annotations:
summary: "探测失败告警"
description: "对目标的探测失败。"
- alert: HttpUncompressedBodyTooLargeAlert
expr: probe_http_uncompressed_body_length > 1048576
for: 10m
labels:
severity: warning
annotations:
summary: "HTTP未压缩内容过大告警"
description: "目标的HTTP响应未压缩的内容长度超过1 MB 当前值为: {{ $value }}"
- alert: ProbeIPAddrHashMismatchAlert
expr: probe_ip_addr_hash > 1
for: 5m
labels:
severity: warning
annotations:
summary: "DNS域名解析地址改变"
description: "DNS域名解析地址改变"
- alert: ProbeHttpSSLErrorAlert
expr: probe_http_ssl == 0
for: 5m
labels:
severity: warning
annotations:
summary: "探测HTTP SSL错误告警"
description: "当前url 没有启用SSL/TLS 加密"
