monexec icon indicating copy to clipboard operation
monexec copied to clipboard

Feature request - REST API - healtcheck endpoint

Open thim81 opened this issue 6 years ago • 3 comments

Hi Reddec,

Another idea, the REST API now exposes per instance the config and status.

/instance/{name}:
    get:
      summary: Get instance config and status

This is very usefull from a management point of view, but it would also be usefull to have a "healthcheck" endpoint that just reports the status of a service and/or an endpoint that reports only the status of all managed services.

These healtcheck endpoints could be added to monitoring tools, that would report a system as down if the healtcheck endpoint would report a certain error code.

Idea:

/healtchecks/: get: summary: Get instance health status of all services that should be running

/healtcheck/{name}: get: summary: Get instance health status of a service

Response codes:

  • 200: if the service is running or stopped, body: "service xxx is up"
  • 5xx: if the service is not running, while it would be expected to be running, body "service xxx is down"

thim81 avatar Jun 13 '19 08:06 thim81

If I look at the

router.GET("/instance/:name", func(gctx *gin.Context) {
		name := gctx.Param("name")
		for _, sv := range pl.Instances() {
			if sv.Config().Name == name {
				gctx.JSON(http.StatusOK, sv)
				return
			}
		}
		gctx.AbortWithStatus(http.StatusNotFound)
	})

I think I'm able to create a PR for the Healtcheck feature, but I first want to present it to you before giving it a try.

thim81 avatar Jun 13 '19 08:06 thim81

Hi Thim!

It looks OK for me. Maybe bit redundant, because basically you can combine endpoints /instance and /supervisors plus some logic. However, I fully agree that for automation purpose existent approach is not a good way.

reddec avatar Jun 13 '19 10:06 reddec

This endpoint would mostly be used for monitoring purposes and unsecured, so we don't want to expose the full service info.

I'll give it a GO ;-)

thim81 avatar Jun 13 '19 10:06 thim81