gravitee-io / issues

Gravitee.io - API Platform - Issues
64 stars 26 forks source link

Enhancement Request: Add Health Check Endpoint to graviteeio/apim-management-api #9706

Closed B3ns44d closed 4 months ago

B3ns44d commented 4 months ago

Feature Myabe?

feature-myabe

feature-myabe

As a SRE

I want to have a dedicated health check endpoint (/health) in the graviteeio/apim-management-api API container

So that I can easily monitor the health and status of the API management system in Docker, Kubernetes, and other environments.

Additional information

additional-information

additional-information

Acceptance criteria

acceptance-criteria

acceptance-criteria

Developer sub-tasks

developer-sub-tasks

developer-sub-tasks

B3ns44d commented 4 months ago

Well, I've found this endpoint and it seems like the health endpoint for Gravitee components, and I've created this script to make it easy to perform health checks with Docker:

#!/bin/sh

username="admin"
password="adminadmin"
url="http://localhost:18083/_node/health"

log() {
    echo "$(date +"%Y-%m-%d %T") - $1"
}

log "Fetching health check data from $url"
result=$(curl -f -s -u "${username}:${password}" "${url}")

if [ $? -ne 0 ]; then
    log "Error: Failed to fetch health data"
    exit 1
fi

check_component_health() {
    component=$1
    health_status=$(echo "$result" | jq -r ".[\"${component}\"]|.healthy")
    if [ "$health_status" != "true" ]; then
        log "Component $component is not healthy"
        return 1
    else
        log "Component $component is healthy"
    fi
}

if check_component_health "management-repository" &&
   check_component_health "gravitee-apis" &&
   check_component_health "repository-analytics"; then
    log "All components are healthy"
    exit 0
else
    log "One or more components are unhealthy"
    exit 1
fi

ref: https://docs.gravitee.io/apim/1.x/apim_installguide_management_api_technical_api.html