Skip to main content

Overview

The /health endpoint provides a simple health check to verify that the Permission Mongo server is running and responsive. This endpoint is useful for basic uptime monitoring and load balancer health checks.

Endpoint

GET /health

Authentication

No authentication required. This endpoint is publicly accessible.

Request

No request parameters or body required.

Example Request

curl http://localhost:8080/health

Response

Success Response (200 OK)

Returns a JSON object indicating the server is healthy.
{
  "data": {
    "status": "ok",
    "goroutines": 42
  },
  "meta": {
    "request_id": "req_abc123xyz"
  }
}

Response Fields

FieldTypeDescription
data.statusstringHealth status. Always returns "ok" when the server is running
data.goroutinesintegerNumber of active goroutines in the server process
meta.request_idstringUnique identifier for the request

Implementation Details

The health check endpoint:
  • Updates the permission_mongo_server_goroutines Prometheus metric before responding
  • Does not check external dependencies (MongoDB, Redis)
  • Always returns 200 OK if the server is running
  • Bypassed by authentication middleware for fast response times
For a more comprehensive readiness check that includes dependency status, see the GET /ready endpoint.

Source Code Reference

Implementation: ~/workspace/source/pkg/api/server.go:409
func (s *Server) healthHandler(ctx *fasthttp.RequestCtx) {
    // Update server metrics
    metrics.GoroutinesCount.Set(float64(runtime.NumGoroutine()))

    WriteJSON(ctx, fasthttp.StatusOK, map[string]interface{}{
        "status":     "ok",
        "goroutines": runtime.NumGoroutine(),
    })
}

Use Cases

  • Load Balancer Health Checks: Configure your load balancer to poll this endpoint
  • Uptime Monitoring: Use monitoring tools to verify service availability
  • Kubernetes Liveness Probes: Simple check to restart unhealthy pods
  • CI/CD Pipeline Validation: Verify deployment success

Build docs developers (and LLMs) love