hotosm / galaxy-api

Backend to fetch data from Underpass
https://galaxy-api.hotosm.org/latest/redoc
GNU Affero General Public License v3.0
14 stars 5 forks source link

[FEATURE] Health check for API #306

Open ramyaragupathy opened 2 years ago

ramyaragupathy commented 2 years ago

Similar to Tasking Manager API - https://tasking-manager-tm4-production-api.hotosm.org/api/v2/system/heartbeat/ - it will be good to have one simple endpoint in Galaxy API that checks for the accessibility status.

cc @kshitijrajsharma @emi420 @dakotabenjamin @eternaltyro

kshitijrajsharma commented 2 years ago

IMO health check for each endpoint with the sample request or may be with dummy dataset wrt production API or checkout the latest code on the master ! I really liked the health check for the github ! https://www.githubstatus.com/ With this practice when there is a new endpoint developer is required to setup a health check for that particular endpoint with the dummy dataset or request !

d-rita commented 2 years ago

How would the dummy dataset work? From the articles I have read so far, we would have to use an external service like New Relic, Postman, etc to monitor the API endpoints at given intervals. Codewise, we can monitor dependencies like the databases. If you have a resource that could help with this task, could you please share it? cc: @kshitijrajsharma

kshitijrajsharma commented 2 years ago

Yeah , Dummy dataset is a .sql file which will be can be used for tests for specific input in the Api endpoint while specifying the output of API . I have done one for Mapathon summary endpoint , which will not only validate the query but it will run the actual workflow and tests the output of that endpoint in tests In that way we can be sure that endpoint is working code wise and for the real production API link , basically Idea is to do it from production by setting up services , And the sample request body can lie inside repo and should be dynamic so that service can pick it from for respective endpoints @eternaltyro will have more insight on this since we are discussing API health check for each endpoint during previous deployment ! For this PR , we can start with database link and improvise , I would love to hear from @robsavoye and @ramyaragupathy

ramyaragupathy commented 2 years ago

@d-rita @kshitijrajsharma - let's start with a simple endpoint, that returns the status of the backend API server. Once that's in place, we can create checks for different endpoints.

d-rita commented 2 years ago

From today's discussion: the plan is to create a /health/ endpoint where we shall test that different API endpoints are working as expected, i.e. authentication, mapathon summary, mapathon detail, and raw data for the start. If an endpoint returns a 200 OK response, then it is working fine and hence healthy. If not, it's unhealthy. This /health endpoint will help API users know the status of particular endpoints they are using and create checks for them as needed.

Details: