Search code examples
httpmarathon

How to create a healthcheck HTTP endpoint for Marathon task?


I am trying to setup a custom http health check for a task that I will be running in Marathon.

From what I have been reading, Marathon gives you the ability to create a custom health checks by implementing an endpoint in your app with the logic of capturing what makes your app healthy.

I understand how to connect to the endpoint through the Marathon GUI, but I can’t find any resources on how to actually create an end point on a Marathon task.


Solution

  • The general documentation is here: https://mesosphere.github.io/marathon/docs/

    The specific documentation for your question can be found at: https://mesosphere.github.io/marathon/docs/health-checks.html

    For example you can start an application (combined with docker containers) with health checks with the following marathon configuration:

    {
       "id":"app",
       "cpus":0.25,
       "mem":1024,
       "instances":2,
       "healthChecks":[
          {
             "protocol":"HTTP",
             "path":"/",
             "portIndex":0,
             "timeoutSeconds":10,
             "gracePeriodSeconds":10,
             "intervalSeconds":2,
             "maxConsecutiveFailures":10
          }
       ],
       "container":{
          "type":"DOCKER",
          "docker":{
             "image":"nginx",
             "network":"BRIDGE",
             "portMappings":[
                {
                   "hostPort":0,
                   "containerPort":80,
                   "protocol":"tcp"
                }
             ]
          }
       }
    }