SSHOC / sshoc-marketplace-backend

Code for the backend
Apache License 2.0
2 stars 0 forks source link

Create a status API endpoint #400

Closed KlausIllmayer closed 10 months ago

KlausIllmayer commented 1 year ago

For monitoring it would be great to have a dedicated API endpoint like api/status where the backend sends back either true or false, based on the availability of the database.

tparkola commented 10 months ago

The healthcheck endpoint is under /actuator/health/ - details are visible to administrators only, but feel free to play with configuration accordingly (see https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html).

KlausIllmayer commented 10 months ago

Thanks for this, looks very interesting and gives detailed information when called by administrator. For documentation: the API call to get the health is {API-Base-URL}/actuator/health (use auth bearer token as administrator to get detail information on database, disk, solr and ping state) It returns a status message UP (JSON format, key "status") when everything is fine. Not sure, what it will return, when there is a problem. I guess it depends on the state of the problem. I tried it out by shutting down the database. In such a case I got a 502 Bad Gateway message. Not sure, if this is what is expected - I somehow thought it will give me a different status message and not a 502. Maybe I did something wrong, on the other hand the issue is, that the liveness probe of k8s restarts the pod, which would explain the 502. Need to see what happens, if we change the current liveness check to the new health check.

See for more details: https://docs.spring.io/spring-boot/docs/3.1.3/actuator-api/htmlsingle/#health