2017-04-04 16:33:22 +00:00
---
layout: api
page_title: Check - Agent - HTTP API
2020-04-07 18:55:19 +00:00
description: The /agent/check endpoints interact with checks on the local agent in Consul.
2017-04-04 16:33:22 +00:00
---
# Check - Agent HTTP API
2023-02-28 22:09:56 +00:00
Refer to [Define Health Checks](/consul/docs/services/usage/checks) for information about Consul health check capabilities.
2022-07-27 21:03:06 +00:00
The `/agent/check` endpoints interact with health checks
managed by the local agent in Consul.
2017-04-04 16:33:22 +00:00
These should not be confused with checks in the catalog.
## List Checks
This endpoint returns all checks that are registered with the local agent. These
checks were either provided through configuration files or added dynamically
using the HTTP API.
It is important to note that the checks known by the agent may be different from
those reported by the catalog. This is usually due to changes being made while
there is no leader elected. The agent performs active
2023-01-25 16:52:43 +00:00
[anti-entropy](/consul/docs/architecture/anti-entropy), so in most situations
2017-04-04 16:33:22 +00:00
everything will be in sync within a few seconds.
2022-03-19 20:32:38 +00:00
@include 'http_api_results_filtered_by_acls.mdx'
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | --------------- | ------------------ |
| `GET` | `/agent/checks` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------ |
| `NO` | `none` | `none` | `node:read,service:read` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2019-04-16 16:00:15 +00:00
- `filter` `(string: "")` - Specifies the expression used to filter the
queries results prior to returning the data.
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Return only the checks in the specified namespace.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/checks
2017-04-04 16:33:22 +00:00
```
### Sample Response
```json
{
"service:redis": {
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
2017-11-23 21:16:42 +00:00
"ServiceName": "redis",
2021-08-02 18:55:23 +00:00
"ServiceTags": ["primary"],
2021-08-03 22:26:49 +00:00
"Interval": "10s",
"Timeout": "1s"
2021-08-02 18:55:23 +00:00
"Type": "tcp",
"ExposedPort": 0,
"Definition": {},
"Namespace": "default",
"CreateIndex": 0,
"ModifyIndex": 0
2017-04-04 16:33:22 +00:00
}
}
```
2019-04-16 16:00:15 +00:00
### Filtering
The filter will be executed against each health check value in the results map with
the following selectors and filter operations being supported:
2019-07-23 18:45:20 +00:00
| Selector | Supported Operations |
2020-04-06 20:27:35 +00:00
| ------------- | -------------------------------------------------- |
2019-07-23 18:45:20 +00:00
| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ServiceTags` | In, Not In, Is Empty, Is Not Empty |
| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches |
2019-04-16 16:00:15 +00:00
2017-04-04 16:33:22 +00:00
## Register Check
This endpoint adds a new check to the local agent. Checks may be of script,
2022-06-06 19:13:19 +00:00
HTTP, TCP, UDP, or TTL type. The agent is responsible for managing the status of the
2017-04-04 16:33:22 +00:00
check and keeping the Catalog in sync.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ----------------------- | ------------------ |
| `PUT` | `/agent/check/register` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | -------------------------- |
| `NO` | `none` | `none` | `node:write,service:write` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you register.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
### JSON Request Body Schema
2017-04-04 16:33:22 +00:00
- `Name` `(string: <required>)` - Specifies the name of the check.
2020-04-01 09:49:20 +00:00
- `ID` `(string: "")` - Specifies a unique ID for this check on the node.
2017-04-04 16:33:22 +00:00
This defaults to the `"Name"` parameter, but it may be necessary to provide an
2021-05-20 00:24:54 +00:00
ID for uniqueness. This value will return in the response as `"CheckId"`.
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
- `Namespace` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you register.
This field takes precedence over the `ns` query parameter,
one of several [other methods to specify the namespace](#methods-to-specify-namespace).
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
- `Interval` `(string: "")` - Specifies the frequency at which to run this
2022-06-06 19:13:19 +00:00
check. This is required for HTTP, TCP, and UDP checks.
2017-04-04 16:33:22 +00:00
- `Notes` `(string: "")` - Specifies arbitrary information for humans. This is
not used by Consul internally.
- `DeregisterCriticalServiceAfter` `(string: "")` - Specifies that checks
associated with a service should deregister after this time. This is specified
as a time duration with suffix like "10m". If a check is in the critical state
for more than this configured value, then its associated service (and all of
its associated checks) will automatically be deregistered. The minimum timeout
is 1 minute, and the process that reaps critical services runs every 30
seconds, so it may take slightly longer than the configured timeout to trigger
the deregistration. This should generally be configured with a timeout that's
much, much longer than any expected recoverable outage for the given service.
2017-10-10 23:37:08 +00:00
- `Args` `(array<string>)` - Specifies command arguments to run to update the
status of the check. Prior to Consul 1.0, checks used a single `Script` field
to define the command to run, and would always run in a shell. In Consul
1.0, the `Args` array was added so that checks can be run without a shell. The
2017-10-18 10:34:35 +00:00
`Script` field is deprecated, and you should include the shell in the `Args` to
2017-10-10 23:37:08 +00:00
run under a shell, eg. `"args": ["sh", "-c", "..."]`.
2017-04-04 16:33:22 +00:00
2017-10-18 18:28:39 +00:00
-> **Note:** Consul 1.0 shipped with an issue where `Args` was erroneously named
2020-04-06 20:27:35 +00:00
`ScriptArgs` in this API. Please use `ScriptArgs` with Consul 1.0 (that will
continue to be accepted in future versions of Consul), and `Args` in Consul
1.0.1 and later.
2017-10-18 18:28:39 +00:00
2018-07-13 04:14:36 +00:00
- `AliasNode` `(string: "")` - Specifies the ID of the node for an alias check.
If no service is specified, the check will alias the health of the node.
If a service is specified, the check will alias the specified service on
this particular node.
- `AliasService` `(string: "")` - Specifies the ID of a service for an
alias check. If the service is not registered with the same agent,
`AliasNode` must also be specified. Note this is the service _ID_ and
not the service _name_ (though they are very often the same).
2017-04-04 16:33:22 +00:00
- `DockerContainerID` `(string: "")` - Specifies that the check is a Docker
check, and Consul will evaluate the script every `Interval` in the given
container using the specified `Shell`. Note that `Shell` is currently only
supported for Docker checks.
2018-02-10 00:02:27 +00:00
- `GRPC` `(string: "")` - Specifies a `gRPC` check's endpoint that supports the standard
[gRPC health checking protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
The state of the check will be updated at the given `Interval` by probing the configured
2020-02-03 09:19:06 +00:00
endpoint. Add the service identifier after the `gRPC` check's endpoint in the following format to check for a specific service instead of the whole gRPC server `/:service_identifier`.
2018-02-10 00:02:27 +00:00
- `GRPCUseTLS` `(bool: false)` - Specifies whether to use TLS for this `gRPC` health check.
If TLS is enabled, then by default, a valid TLS certificate is expected. Certificate
verification can be turned off by setting `TLSSkipVerify` to `true`.
2021-07-25 20:08:44 +00:00
- `H2PING` `(string "")` - Specifies an address that uses http2 to run a ping check on.
2021-04-09 19:12:10 +00:00
At the specified `Interval`, a connection is made to the address, and a ping is sent.
If the ping is successful, the check will be classified as `passing`, otherwise it will be marked as `critical`.
2021-10-07 06:29:41 +00:00
TLS is used by default. To disable TLS and use h2c, set `H2PingUseTLS` to `false`.
If TLS is enabled, a valid SSL certificate is required by default, but verification can be removed with `TLSSkipVerify`.
- `H2PingUseTLS` `(bool: true)` - Specifies if TLS should be used for H2PING check.
2021-07-25 20:08:44 +00:00
If TLS is enabled, a valid SSL certificate is required by default, but verification can be removed with `TLSSkipVerify`.
2021-04-09 19:12:10 +00:00
2017-04-04 16:33:22 +00:00
- `HTTP` `(string: "")` - Specifies an `HTTP` check to perform a `GET` request
against the value of `HTTP` (expected to be a URL) every `Interval`. If the
2020-04-06 20:27:35 +00:00
response is any `2xx` code, the check is `passing`. If the response is `429 Too Many Requests`, the check is `warning`. Otherwise, the check is
2017-04-04 16:33:22 +00:00
`critical`. HTTP checks also support SSL. By default, a valid SSL certificate
is expected. Certificate verification can be controlled using the
`TLSSkipVerify`.
2017-08-16 16:18:46 +00:00
- `Method` `(string: "")` - Specifies a different HTTP method to be used
for an `HTTP` check. When no value is specified, `GET` is used.
2020-02-10 16:27:12 +00:00
- `Body` `(string: "")` - Specifies a body that should be sent with `HTTP` checks.
2022-04-01 21:31:15 +00:00
- `DisableRedirects` `(bool: false)` - Specifies whether to disable following HTTP
redirects when performing an HTTP check.
2017-08-16 16:18:46 +00:00
- `Header` `(map[string][]string: {})` - Specifies a set of headers that should
be set for `HTTP` checks. Each header can have multiple values.
2018-02-10 00:02:27 +00:00
- `Timeout` `(duration: 10s)` - Specifies a timeout for outgoing connections in the
2022-06-06 19:13:19 +00:00
case of a Script, HTTP, TCP, UDP, or gRPC check. Can be specified in the form of "10s"
2018-02-10 00:02:27 +00:00
or "5m" (i.e., 10 seconds or 5 minutes, respectively).
2019-06-26 15:43:25 +00:00
- `OutputMaxSize` `(positive int: 4096)` - Allow to put a maximum size of text
for the given check. This value must be greater than 0, by default, the value
is 4k.
The value can be further limited for all checks of a given agent using the
`check_output_max_size` flag in the agent.
2021-02-25 06:35:34 +00:00
- `TLSServerName` `(string: "")` - Specifies an optional string used to set the
SNI host when connecting via TLS.
For an `HTTP` check, this value is set automatically if the URL uses a hostname
(not an IP address).
2017-04-04 16:33:22 +00:00
- `TLSSkipVerify` `(bool: false)` - Specifies if the certificate for an HTTPS
check should not be verified.
- `TCP` `(string: "")` - Specifies a `TCP` to connect against the value of `TCP`
(expected to be an IP or hostname plus port combination) every `Interval`. If
the connection attempt is successful, the check is `passing`. If the
connection attempt is unsuccessful, the check is `critical`. In the case of a
hostname that resolves to both IPv4 and IPv6 addresses, an attempt will be
made to both addresses, and the first successful connection attempt will
result in a successful check.
2023-09-05 20:34:44 +00:00
- `TCPUseTLS` `(bool: false)` - Specifies whether to use TLS for this `TCP` health check.
If TLS is enabled, then by default, a valid TLS certificate is expected. Certificate
verification can be turned off by setting `TLSSkipVerify` to `true`.
2022-06-06 19:13:19 +00:00
- `UDP` `(string: "")` - Specifies a `UDP` IP address/hostname and port.
The check sends datagrams to the value specified at the interval specified in the `Interval` configuration.
If the datagram is sent successfully or a timeout is returned, the check is set to the `passing` state.
The check is logged as `critical` if the datagram is sent unsuccessfully.
2022-10-14 11:32:55 +00:00
- `OSService` `(string: "")` - Specifies the identifier of an OS-level service to check. You can specify either `Windows Services` on Windows or `SystemD` services on Unix.
2022-06-07 17:25:24 +00:00
2021-08-02 18:55:23 +00:00
- `TTL` `(duration: 10s)` - Specifies this is a TTL check, and the TTL endpoint
must be used periodically to update the state of the check. If the check is not
set to passing within the specified duration, then the check will be set to the failed state.
2017-04-04 16:33:22 +00:00
- `ServiceID` `(string: "")` - Specifies the ID of a service to associate the
registered check with an existing service provided by the agent.
- `Status` `(string: "")` - Specifies the initial status of the health check.
2020-06-29 12:52:35 +00:00
- `SuccessBeforePassing` `(int: 0)` - Specifies the number of consecutive successful
results required before check status transitions to passing. Available for HTTP,
2021-09-14 16:47:52 +00:00
TCP, gRPC, Docker & Monitor checks. Added in Consul 1.7.0.
- `FailuresBeforeWarning` `(int: 0)` - Specifies the number of consecutive unsuccessful
results required before check status transitions to warning. Defaults to the same value
as `FailuresBeforeCritical`. Values higher than `FailuresBeforeCritical` are invalid.
Available for HTTP, TCP, gRPC, Docker & Monitor checks. Added in Consul 1.11.0.
2020-06-29 12:52:35 +00:00
- `FailuresBeforeCritical` `(int: 0)` - Specifies the number of consecutive unsuccessful
results required before check status transitions to critical. Available for HTTP,
2021-09-14 16:47:52 +00:00
TCP, gRPC, Docker & Monitor checks. Added in Consul 1.7.0.
2020-06-29 12:52:35 +00:00
2017-04-04 16:33:22 +00:00
### Sample Payload
```json
{
"ID": "mem",
"Name": "Memory utilization",
2021-08-02 18:55:23 +00:00
"Namespace": "default",
2017-04-04 16:33:22 +00:00
"Notes": "Ensure we don't oversubscribe memory",
"DeregisterCriticalServiceAfter": "90m",
2017-10-10 23:37:08 +00:00
"Args": ["/usr/local/bin/check_mem.py"],
2017-04-04 16:33:22 +00:00
"DockerContainerID": "f972c95ebf0e",
"Shell": "/bin/bash",
2017-08-16 16:24:28 +00:00
"HTTP": "https://example.com",
"Method": "POST",
2020-05-19 18:32:38 +00:00
"Header": { "Content-Type": ["application/json"] },
2020-02-10 16:27:12 +00:00
"Body": "{\"check\":\"mem\"}",
2022-04-01 21:31:15 +00:00
"DisableRedirects": true,
2017-04-04 16:33:22 +00:00
"TCP": "example.com:22",
"Interval": "10s",
2019-11-02 16:34:20 +00:00
"Timeout": "5s",
2017-04-04 16:33:22 +00:00
"TLSSkipVerify": true
}
```
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
--request PUT \
--data @payload.json \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/check/register
2017-04-04 16:33:22 +00:00
```
## Deregister Check
This endpoint remove a check from the local agent. The agent will take care of
deregistering the check from the catalog. If the check with the provided ID does
not exist, no action is taken.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ----------------------------------- | ------------------ |
| `PUT` | `/agent/check/deregister/:check_id` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | -------------------------- |
| `NO` | `none` | `none` | `node:write,service:write` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
- `check_id` `(string: "")` - Specifies the unique ID of the check to deregister.
### Query Parameters
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you deregister.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
--request PUT \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/check/deregister/my-check-id
2017-04-04 16:33:22 +00:00
```
## TTL Check Pass
This endpoint is used with a TTL type check to set the status of the check to
`passing` and to reset the TTL clock.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ----------------------------- | ------------------ |
| `PUT` | `/agent/check/pass/:check_id` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | -------------------------- |
| `NO` | `none` | `none` | `node:write,service:write` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
- `check_id` `(string: "")` - Specifies the unique ID of the check to use.
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2017-04-04 16:33:22 +00:00
- `note` `(string: "")` - Specifies a human-readable message. This will be
passed through to the check's `Output` field.
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you update.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2020-12-11 12:23:05 +00:00
--request PUT \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/check/pass/my-check-id
2017-04-04 16:33:22 +00:00
```
## TTL Check Warn
This endpoint is used with a TTL type check to set the status of the check to
`warning` and to reset the TTL clock.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ----------------------------- | ------------------ |
| `PUT` | `/agent/check/warn/:check_id` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | -------------------------- |
| `NO` | `none` | `none` | `node:write,service:write` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
- `check_id` `(string: "")` - Specifies the unique ID of the check to use.
### Query Parameters
2017-04-04 16:33:22 +00:00
- `note` `(string: "")` - Specifies a human-readable message. This will be
passed through to the check's `Output` field.
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you update.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/check/warn/my-check-id
2017-04-04 16:33:22 +00:00
```
## TTL Check Fail
This endpoint is used with a TTL type check to set the status of the check to
`critical` and to reset the TTL clock.
2022-07-27 21:03:06 +00:00
If you want to manually mark a service as unhealthy,
2023-01-25 16:52:43 +00:00
use [maintenance mode](/consul/api-docs/agent#enable-maintenance-mode)
2022-07-27 21:03:06 +00:00
instead of defining a TTL health check and using this endpoint.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ----------------------------- | ------------------ |
| `PUT` | `/agent/check/fail/:check_id` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | -------------------------- |
| `NO` | `none` | `none` | `node:write,service:write` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
- `check_id` `(string: "")` - Specifies the unique ID of the check to use.
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2017-04-04 16:33:22 +00:00
- `note` `(string: "")` - Specifies a human-readable message. This will be
passed through to the check's `Output` field.
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you update.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/check/fail/my-check-id
2017-04-04 16:33:22 +00:00
```
## TTL Check Update
This endpoint is used with a TTL type check to set the status of the check and
to reset the TTL clock.
2022-07-27 21:03:06 +00:00
If you want to manually mark a service as unhealthy,
2023-01-25 16:52:43 +00:00
use [maintenance mode](/consul/api-docs/agent#enable-maintenance-mode)
2022-07-27 21:03:06 +00:00
instead of defining a TTL health check and using this endpoint.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | ------------------------------- | ------------------ |
| `PUT` | `/agent/check/update/:check_id` | `application/json` |
2017-04-04 16:33:22 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2017-04-04 16:33:22 +00:00
2018-09-06 10:34:28 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | -------------------------- |
| `NO` | `none` | `none` | `node:write,service:write` |
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
- `check_id` `(string: "")` - Specifies the unique ID of the check to use.
2017-04-04 16:33:22 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the check you update.
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
### JSON Request Body Schema
2017-04-04 16:33:22 +00:00
- `Status` `(string: "")` - Specifies the status of the check. Valid values are
`"passing"`, `"warning"`, and `"critical"`.
- `Output` `(string: "")` - Specifies a human-readable message. This will be
passed through to the check's `Output` field.
2022-05-10 15:51:11 +00:00
<!-- Are we missing a Namespace field here? -->
2021-08-02 18:55:23 +00:00
2017-04-04 16:33:22 +00:00
### Sample Payload
```json
{
"Status": "passing",
"Output": "curl reported a failure:\n\n..."
}
```
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2017-04-04 16:33:22 +00:00
$ curl \
--request PUT \
--data @payload.json \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/agent/check/update/my-check-id
2017-04-04 16:33:22 +00:00
```
2022-05-10 15:51:11 +00:00
## Methods to Specify Namespace <EnterpriseAlert inline />
Local agent health check endpoints
support several methods for specifying the namespace of the check resources
with the following order of precedence:
1. `Namespace` field of the JSON request body -
only applies to the [register](#register-check) endpoint
1. `ns` query parameter
1. `X-Consul-Namespace` request header
1. Namespace is inherited from the namespace of the request's ACL token (if any)
1. The `default` namespace