<commit_before>---
title: Health Checks
---

# Health Checks

Health checks may be specified per application to be run against that application's tasks.

- The default health check defers to Mesos' knowledge of the task state `TASK_RUNNING => healthy`
- Marathon provides a `health` member of the task resource
  via the [REST API]({{ site.baseurl }}/docs/rest-api.html).

A health check is considered passing if (1) its HTTP response code is between
200 and 399, inclusive, and (2) its response is received within the
`timeoutSeconds` period. If a task fails more than `maxConseutiveFailures` health
checks consecutively, that task is killed.

##### Example usage

```json
{
  "path": "/api/health",
  "portIndex": 0,
  "protocol": "HTTP",
  "gracePeriodSeconds": 300,
  "intervalSeconds": 60,
  "timeoutSeconds": 20,
  "maxConsecutiveFailures": 3,
  "ignoreHttp1xx": false,
}
```

OR

```json
{
  "portIndex": 0,
  "protocol": "TCP",
  "gracePeriodSeconds": 300,
  "intervalSeconds": 60,
  "timeoutSeconds": 20,
  "maxConsecutiveFailures": 0
}
```

OR

*Note:* Command health checks are currently not compatible with dockerized tasks. 

```json
{
  "protocol": "COMMAND",
  "command": { "value": "curl -f -X GET http://$HOST:$PORT0/health" },
  "gracePeriodSeconds": 300,
  "intervalSeconds": 60,
  "timeoutSeconds": 20,
  "maxConsecutiveFailures": 3
}<commit_msg>Fixes #2352 - Update healtcheck documentation<commit_after>---
title: Health Checks
---

# Health Checks

Health checks may be specified per application to be run against that application's tasks.

- The default health check defers to Mesos' knowledge of the task state `TASK_RUNNING => healthy`
- Marathon provides a `health` member of the task resource
  via the [REST API]({{ site.baseurl }}/docs/rest-api.html).

A health check is considered passing if (1) its HTTP response code is between
200 and 399, inclusive, and (2) its response is received within the
`timeoutSeconds` period. If a task fails more than `maxConseutiveFailures` health
checks consecutively, that task is killed.

##### Example usage

```json
{
  "path": "/api/health",
  "portIndex": 0,
  "protocol": "HTTP",
  "gracePeriodSeconds": 300,
  "intervalSeconds": 60,
  "timeoutSeconds": 20,
  "maxConsecutiveFailures": 3,
  "ignoreHttp1xx": false,
}
```

OR

```json
{
  "portIndex": 0,
  "protocol": "TCP",
  "gracePeriodSeconds": 300,
  "intervalSeconds": 60,
  "timeoutSeconds": 20,
  "maxConsecutiveFailures": 0
}
```

OR

*Note:* Command health checks in combination with dockerized tasks were
broken in Mesos v0.23.0 and v0.24.0. This issue has been fixed in
v0.23.1 and v0.24.1.

See [MESOS-3136](https://issues.apache.org/jira/browse/MESOS-3136) for
more details.

```json
{
  "protocol": "COMMAND",
  "command": { "value": "curl -f -X GET http://$HOST:$PORT0/health" },
  "gracePeriodSeconds": 300,
  "intervalSeconds": 60,
  "timeoutSeconds": 20,
  "maxConsecutiveFailures": 3
}
{'fraction_non_alphanumeric': 0.1339712918660287, 'fraction_numerical': 0.03417634996582365, 'mean_word_length': 4.410351201478743, 'pattern_counts': {'":': 42, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '742853', 'n_tokens_mistral': 1043, 'n_tokens_neox': 940, 'n_words': 331}