规则
prometeus blackbox get方式设置非200状态码或者返回 特定内容即为成功
思路:在blackbox上设置模板
http_get:
prober: http
timeout: 15s
http:
valid_status_codes: [503]
preferred_ip_protocol: "ip4"
method: GET
fail_if_body_not_matches_regexp:
- '"status":"UP"'
这表示返回503和"status":"up"的才返回正确,然后再promethes配置文件引用该模块
- job_name: 'get-test'
metrics_path: /probe
params:
module: [http_get]
static_configs:
- targets: ['http://192.168.11.25:8081/actuator/health']
labels:
instance: 'http://192.168.11.25:8081/actuator/health'
tags: 'get-test'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 192.168.11.178:9115