Skip to main content

Endpoint

GET /health
Returns the health status of the Slung server. Use this endpoint for monitoring, load balancer health checks, and operational readiness verification.

Request

No parameters or headers required.
curl http://0.0.0.0:2077/health

Response

status
string
required
Always returns "ok" when the server is operational

Success Response

Status Code: 200 OK Headers:
Content-Type: application/json
Body:
{
  "status": "ok"
}

Implementation Details

The health endpoint is implemented in src/main.zig:360-367:
fn handleHealth(_: *AppContext, _: *http.Request, res: *http.Response) !void {
    try res.header("Content-Type", "application/json");
    res.body =
        \\{
        \\ "status": "ok",
        \\}
    ;
}
The endpoint:
  • Does not access application state
  • Returns immediately without blocking
  • Always succeeds if the HTTP server is running

Use Cases

Docker Health Check

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:2077/health || exit 1

Kubernetes Liveness Probe

livenessProbe:
  httpGet:
    path: /health
    port: 2077
  initialDelaySeconds: 3
  periodSeconds: 10

Monitoring Script

#!/bin/bash
if curl -sf http://0.0.0.0:2077/health | grep -q '"status":"ok"'; then
  echo "Slung is healthy"
  exit 0
else
  echo "Slung is down"
  exit 1
fi

Limitations

The /health endpoint only verifies that the HTTP server is responding. It does not check:
  • Database write availability
  • Memory pressure
  • Disk space
  • Internal component health (TSM tree, channel capacity, etc.)
For production deployments, consider implementing application-level health monitoring beyond this basic endpoint.

Build docs developers (and LLMs) love