Health Check API: Monitoring and Troubleshooting
This page focuses on probe strategy, Kubernetes examples, scripted checks, and security notes.
Monitoring integration notes
If you use Bearer token (the value of runtime config api.health_token), you can avoid JWT cookie expiration and make automated monitoring easier.
Recommended options:
- Recommended: set
api.health_tokenand probe/health/liveor/health/readywithAuthorization: Bearer <token> - Fallback: probe
/(returns307, treated as success in Kubernetes) to ensure the process is up - Fallback: login + cookies +
/health(for monitors that already have a login step)
Kubernetes probe example (Bearer token)
yaml
apiVersion: v1
kind: Pod
spec:
containers:
- name: shortlinker
image: e1saps/shortlinker
livenessProbe:
httpGet:
path: /health/live
port: 8080
httpHeaders:
- name: Authorization
value: "Bearer your_health_token"
initialDelaySeconds: 10
periodSeconds: 10Kubernetes probe example (simple liveness)
yaml
apiVersion: v1
kind: Pod
spec:
containers:
- name: shortlinker
image: e1saps/shortlinker
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 10
periodSeconds: 10Script example (login + health check)
bash
#!/bin/bash
set -euo pipefail
ADMIN_TOKEN="your_admin_token"
BASE_URL="http://localhost:8080"
COOKIE_JAR="$(mktemp)"
curl -sS -X POST \
-H "Content-Type: application/json" \
-c "$COOKIE_JAR" \
-d "{\"password\":\"${ADMIN_TOKEN}\"}" \
"${BASE_URL}/admin/v1/auth/login" >/dev/null
curl -sS -b "$COOKIE_JAR" "${BASE_URL}/health"Security notes
- Use a strong admin password (
api.admin_token) - Restrict access to health endpoints to trusted networks
- Use HTTPS in production and configure cookie security correctly