healthy-checker/services/default.yaml

91 lines
2.4 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ================================
# SERVICE CONFIG
# ================================
service: default-service # Tên service (duy nhất trong toàn hệ thống)
enabled: false # true = bật check, false = bỏ qua service này
interval: 30 # Chu kỳ chạy health check (giây)
# ================================
# CHECK LIST
# ================================
checks:
# ------------------------------------------------
# 1⃣ LOGIN CHECK (TOKEN TRONG RESPONSE BODY)
# - API trả access_token trong JSON
# - Token sẽ được save vào context
# ------------------------------------------------
- type: http # Loại check: http | shell
name: login-token # Tên check
url: http://localhost:4000/api/v1/admin/auth/login
method: POST
timeout: 5
body:
email: admin@example.com
password: Admin@1234
# Điều kiện pass
expect:
status_code: 200
json:
access_token: $.data.access_token
# ↑ JSONPath phải tồn tại
# Lưu token vào context
save:
token: $.data.access_token
# context["token"] = response.data.access_token
# cookies: __cookies__ => Trường hợp dùng cho cần save cookie
# 👉 Check này BLOCKING
# 👉 Fail là các check phụ thuộc không chạy
# ------------------------------------------------
# 2⃣ ME CHECK (DÙNG TOKEN TỪ CONTEXT)
# - Authorization header dùng {{token}}
# ------------------------------------------------
- type: http
name: me
url: http://localhost:4000/api/v1/admin/me
method: GET
timeout: 3
headers:
Authorization: "Bearer {{token}}"
# ↑ token lấy từ context của service này
expect:
status_code: 200
# ------------------------------------------------
# 3⃣ HEALTH CHECK (ĐỘC LẬP)
# - Không cần login
# - Login fail vẫn chạy
# ------------------------------------------------
- type: http
name: health
url: http://localhost:4000/health
method: GET
timeout: 2
expect:
status_code: 200
independent: true # 🔥 Không phụ thuộc login
# ------------------------------------------------
# 4⃣ PROCESS CHECK (SHELL)
# - Kiểm tra process OS
# -> Chưa test nào dùng thì viết tiếp
# ------------------------------------------------
- type: shell
name: process
command: "pgrep -f auth-service"
independent: true