0

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.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Jason
  • 23
  • 2

1 Answers1

0

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"
            }
         ]
      }
   }
}
unterstein
  • 79
  • 5
  • Hello, I read that documentation and understand how to connect to a health point endpoint (/path) but, my issues is actually creating and setting up the http endpoint with the logic to define how my health check should work.. – Jason Apr 13 '17 at 20:21
  • How you set up a http endpoint is very dependend on the technologies you are using. Consider including a check what makes your application healthy: - checking if all local restrictions are ok, for example disk - connectivity to all dependend other applications, for example the database – unterstein Apr 18 '17 at 08:13
  • My task is using a simple bash script to start a process. I will then be implementing my logic for a health check by using another bash script with grep to determine if the process is running. If it not running then my logic will determine that it is unhealthy. What I’m trying to accomplish is to have the marathon scheduler health check connect to my health check logic on a task instances. If I used HTTP would I need additional technologies to host a webserver in order to create an endpoint with my health check logic? Should I being implementing my health check logic by other means? – Jason Apr 18 '17 at 16:17
  • You could also use a CMD health check. In this case you would not need to expose a HTTP api. In this case the configured command is executed within your running container and can run every command available from there. See this example: ``` { "protocol": "COMMAND", "command": { "value": "cmd/to/healthcheckscipt.sh" }, "gracePeriodSeconds": 60, "intervalSeconds": 60, "timeoutSeconds": 2, "maxConsecutiveFailures": 3 } ``` – unterstein Apr 20 '17 at 15:02
  • hey @Jason, was your health check successful? – unterstein Sep 05 '17 at 10:18