Health Check
Endpoints de health check, liveness e readiness probes para monitoramento e orquestracao
Health Check
Endpoints publicos para monitoramento do servico. Nao requerem autenticacao.
Ideais para configurar probes do Kubernetes, Docker health checks e balanceadores de carga.
GET /health
Health check completo com detalhes do servico e status das dependencias (PostgreSQL, Redis, Meta Cloud API).
Auth: Publico.
Curl:
curl http://localhost:8200/healthResposta (200 OK) — Servico saudavel:
{
"service": "waba-connector",
"version": "2.0.0",
"status": "healthy",
"dependencies": {
"database": "healthy",
"redis": "healthy",
"meta_api": "healthy"
}
}Resposta (200 OK) — Servico degradado:
{
"service": "waba-connector",
"version": "2.0.0",
"status": "degraded",
"dependencies": {
"database": "healthy",
"redis": "unhealthy",
"meta_api": "healthy"
}
}O status sera degraded quando alguma dependencia estiver indisponivel. Operacoes que dependem do componente afetado falharao, mas o servico continua respondendo.
GET /health/live
Liveness probe — verifica se o processo esta vivo e respondendo.
Nao faz verificacoes externas, retornando imediatamente. Usado pelo Kubernetes para reiniciar o container caso ele trave.
Auth: Publico.
Curl:
curl http://localhost:8200/health/liveResposta (200 OK):
{
"status": "ok"
}GET /health/ready
Readiness probe — verifica se o servico esta pronto para receber trafego.
Valida conexao com PostgreSQL, Redis e disponibilidade da Meta Cloud API. Enquanto retornar not_ready, o orquestrador nao deve enviar trafego para esta instancia.
Auth: Publico.
Curl:
curl http://localhost:8200/health/readyResposta (200 OK) — Pronto:
{
"status": "ready",
"database": "healthy",
"redis": "healthy",
"meta_api": "healthy"
}Resposta (200 OK) — Nao pronto:
{
"status": "not_ready",
"database": "healthy",
"redis": "unhealthy",
"meta_api": "healthy"
}Configuracao Kubernetes
Exemplo de Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: waba-connector
spec:
replicas: 2
selector:
matchLabels:
app: waba-connector
template:
metadata:
labels:
app: waba-connector
spec:
containers:
- name: waba-connector
image: waba-connector:latest
ports:
- containerPort: 8200
livenessProbe:
httpGet:
path: /health/live
port: 8200
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /health/ready
port: 8200
initialDelaySeconds: 10
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 2
startupProbe:
httpGet:
path: /health/live
port: 8200
initialDelaySeconds: 3
periodSeconds: 5
failureThreshold: 10Docker Compose Health Check
services:
connector:
build: .
ports:
- "8200:8200"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8200/health/live"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10sDiferencas entre os Probes
| Probe | Endpoint | Verificacoes | Uso |
|---|---|---|---|
| Liveness | /health/live | Nenhuma (retorno imediato) | Reiniciar container travado |
| Readiness | /health/ready | DB + Redis + Meta API | Controlar trafego do LB |
| Health | /health | DB + Redis + Meta API + metadados | Monitoramento e dashboards |