Skip to main content

Overview

The health check endpoint provides a simple way to verify that the webhook server is running and responding to requests. This endpoint is commonly used for monitoring, load balancer health checks, and container orchestration readiness probes.

Endpoint

GET /webhook_server/healthcheck

Request

No request parameters or headers are required.

Response

status
integer
HTTP status code (always 200 when server is healthy)
message
string
Status message (always “Alive” when server is healthy)

Status Codes

200
Success
Server is running and healthy
If the server is not responding, the request will fail with a connection error or timeout (not an HTTP error response).

Examples

Basic health check

curl http://localhost:5000/webhook_server/healthcheck
Response:
{
  "status": 200,
  "message": "Alive"
}

Health check with verbose output

curl -v http://localhost:5000/webhook_server/healthcheck
Response:
*   Trying 127.0.0.1:5000...
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET /webhook_server/healthcheck HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: application/json
< content-length: 32
<
{"status":200,"message":"Alive"}

Using wget

wget -qO- http://localhost:5000/webhook_server/healthcheck
Response:
{"status":200,"message":"Alive"}

Use Cases

Docker / Podman Health Checks

Add to your Docker Compose configuration:
services:
  github-webhook-server:
    image: ghcr.io/myk-org/github-webhook-server:latest
    healthcheck:
      test: ["CMD", "curl", "--fail", "http://localhost:5000/webhook_server/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

Kubernetes Liveness and Readiness Probes

Add to your Kubernetes deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: github-webhook-server
spec:
  template:
    spec:
      containers:
        - name: webhook-server
          image: ghcr.io/myk-org/github-webhook-server:latest
          livenessProbe:
            httpGet:
              path: /webhook_server/healthcheck
              port: 5000
            initialDelaySeconds: 30
            periodSeconds: 30
            timeoutSeconds: 10
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /webhook_server/healthcheck
              port: 5000
            initialDelaySeconds: 5
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3

Load Balancer Health Checks

NGINX upstream health check:
upstream webhook_servers {
    server webhook1.example.com:5000 max_fails=3 fail_timeout=30s;
    server webhook2.example.com:5000 max_fails=3 fail_timeout=30s;
}

server {
    location / {
        proxy_pass http://webhook_servers;
    }
}
HAProxy health check:
backend webhook_servers
    option httpchk GET /webhook_server/healthcheck
    http-check expect status 200
    server webhook1 webhook1.example.com:5000 check inter 10s
    server webhook2 webhook2.example.com:5000 check inter 10s

Monitoring and Alerting

Prometheus monitoring with blackbox_exporter:
# prometheus.yml
scrape_configs:
  - job_name: 'webhook-server-health'
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - http://webhook-server:5000/webhook_server/healthcheck
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115
Uptime monitoring with cron:
#!/bin/bash
# check_webhook_health.sh

URL="http://localhost:5000/webhook_server/healthcheck"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$URL")

if [ "$RESPONSE" != "200" ]; then
    echo "Webhook server unhealthy! HTTP status: $RESPONSE"
    # Send alert (email, Slack, PagerDuty, etc.)
    exit 1
fi

echo "Webhook server healthy"
exit 0
Schedule with cron:
*/5 * * * * /path/to/check_webhook_health.sh

Systemd Service Health Check

# /etc/systemd/system/webhook-server.service
[Unit]
Description=GitHub Webhook Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/webhook-server
ExecStartPost=/bin/sleep 5
ExecStartPost=/usr/bin/curl --fail http://localhost:5000/webhook_server/healthcheck
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Testing Server Availability

Quick availability test

curl -f http://localhost:5000/webhook_server/healthcheck && echo "Server is up" || echo "Server is down"

Test with timeout

curl --max-time 5 http://localhost:5000/webhook_server/healthcheck

Test and extract status

STATUS=$(curl -s http://localhost:5000/webhook_server/healthcheck | jq -r '.status')
if [ "$STATUS" = "200" ]; then
    echo "Health check passed"
else
    echo "Health check failed"
    exit 1
fi

Continuous monitoring

# Check health every 10 seconds
watch -n 10 'curl -s http://localhost:5000/webhook_server/healthcheck | jq'

Response Time Expectations

The health check endpoint is lightweight and typically responds in:
  • Local requests: < 5ms
  • Same datacenter: < 20ms
  • Cross-region: < 100ms
If response times consistently exceed these values, investigate:
  • Server resource constraints (CPU, memory)
  • Network connectivity issues
  • Server overload from webhook processing

Limitations

The health check endpoint only verifies that:
  • The FastAPI application is running
  • The HTTP server can accept and respond to requests
It does NOT verify:
  • GitHub API connectivity
  • Configuration file validity
  • Database or log file accessibility
  • Background task processing
  • Token validity or rate limits
For comprehensive health monitoring, combine this endpoint with:
  • Log Viewer API for webhook processing metrics
  • Application logs for detailed diagnostics
  • GitHub API rate limit monitoring
  • Custom health checks for critical dependencies

Build docs developers (and LLMs) love