Skip to main content

Overview

The health check endpoint provides service health status information for monitoring and orchestration tools. It returns the current health status of VCVerifier and its components.

Endpoint

GET /health Returns the health status of the VCVerifier service.

Response

Success Response (200 OK) The service is healthy and operational.
status
string
Overall health statusValue: "ok"
timestamp
string
ISO 8601 timestamp of the health checkExample: "2024-01-15T10:30:00Z"
component
object
Component health information
Failure Response (503 Service Unavailable) The service is unhealthy or experiencing issues.
status
string
Overall health statusValue: "degraded" or "unavailable"
timestamp
string
ISO 8601 timestamp of the health check
component
object
Component health information with error details

Examples

Successful Health Check

cURL
curl http://localhost:8080/health
Response
{
  "status": "ok",
  "timestamp": "2024-01-15T10:30:00Z",
  "component": {
    "name": "vcverifier",
    "status": "ok"
  }
}

Using Health Check in Kubernetes

apiVersion: v1
kind: Pod
metadata:
  name: vcverifier
spec:
  containers:
  - name: vcverifier
    image: quay.io/fiware/vcverifier:latest
    livenessProbe:
      httpGet:
        path: /health
        port: 8080
      initialDelaySeconds: 30
      periodSeconds: 10
    readinessProbe:
      httpGet:
        path: /health
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 5

Using Health Check in Docker Compose

version: '3.8'
services:
  vcverifier:
    image: quay.io/fiware/vcverifier:latest
    healthcheck:
      test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

Use Cases

Kubernetes Probes

Configure liveness and readiness probes for container orchestration

Load Balancer Health

Use as health check target for load balancers and reverse proxies

Monitoring Systems

Integrate with monitoring tools like Prometheus, Nagios, or Datadog

CI/CD Pipelines

Verify service availability during deployment and integration tests

Implementation Details

The health check is implemented using the hellofresh/health-go library and registered at application startup. Source: health.go:21-28
func HealthReq(c *gin.Context) {
    checkResult := healthCheck.Measure(c.Request.Context())
    if checkResult.Status == health.StatusOK {
        c.AbortWithStatusJSON(http.StatusOK, checkResult)
    } else {
        c.AbortWithStatusJSON(http.StatusServiceUnavailable, checkResult)
    }
}
The health endpoint does not require authentication and can be accessed without credentials for monitoring purposes.

Excluding from Logs

To prevent health check requests from cluttering your logs, exclude the /health path in your server configuration:
logging:
  pathsToSkip:
    - "/health"
See the Server Configuration documentation for more details.

Build docs developers (and LLMs) love