2015-01-18 00:28:53 +00:00
---
layout: "docs"
page_title: "Agent (HTTP)"
sidebar_current: "docs-agent-http-agent"
description: >
2015-02-07 22:36:10 +00:00
The Agent endpoints are used to interact with the local Consul agent.
2015-01-18 00:28:53 +00:00
---
# Agent HTTP Endpoint
2015-02-07 22:36:10 +00:00
The Agent endpoints are used to interact with the local Consul agent. Usually,
services and checks are registered with an agent which then takes on the
2016-11-25 18:25:09 +00:00
burden of keeping that data synchronized with the cluster. For example, the
2015-03-04 15:22:53 +00:00
agent registers services and checks with the Catalog and performs
[anti-entropy ](/docs/internals/anti-entropy.html ) to recover from outages.
2015-01-18 00:28:53 +00:00
The following endpoints are supported:
* [`/v1/agent/checks` ](#agent_checks ) : Returns the checks the local agent is managing
2015-02-07 22:36:10 +00:00
* [`/v1/agent/services` ](#agent_services ) : Returns the services the local agent is managing
2015-01-18 00:28:53 +00:00
* [`/v1/agent/members` ](#agent_members ) : Returns the members as seen by the local serf agent
* [`/v1/agent/self` ](#agent_self ) : Returns the local node configuration
2016-11-30 18:29:42 +00:00
* [`/v1/agent/reload` ](#agent_reload ) : Causes the local agent to reload its configuration
2015-02-07 22:36:10 +00:00
* [`/v1/agent/maintenance` ](#agent_maintenance ) : Manages node maintenance mode
2016-11-16 21:45:26 +00:00
* [`/v1/agent/monitor` ](#agent_monitor ) : Streams logs from the local agent
2015-02-07 22:36:10 +00:00
* [`/v1/agent/join/<address>` ](#agent_join ) : Triggers the local agent to join a node
2016-11-30 18:29:42 +00:00
* [`/v1/agent/leave` ](#agent_leave ): Triggers the local agent to gracefully shutdown and leave the cluster
2016-11-10 16:09:17 +00:00
* [`/v1/agent/force-leave/<node>` ](#agent_force_leave ): Forces removal of a node
2015-01-18 00:28:53 +00:00
* [`/v1/agent/check/register` ](#agent_check_register ) : Registers a new local check
2015-02-07 22:36:10 +00:00
* [`/v1/agent/check/deregister/<checkID>` ](#agent_check_deregister ) : Deregisters a local check
2016-03-03 01:08:06 +00:00
* [`/v1/agent/check/pass/<checkID>` ](#agent_check_pass ) : Marks a local check as passing
* [`/v1/agent/check/warn/<checkID>` ](#agent_check_warn ) : Marks a local check as warning
* [`/v1/agent/check/fail/<checkID>` ](#agent_check_fail ) : Marks a local check as critical
* [`/v1/agent/check/update/<checkID>` ](#agent_check_update ) : Updates a local check
2015-01-18 00:28:53 +00:00
* [`/v1/agent/service/register` ](#agent_service_register ) : Registers a new local service
2015-02-07 22:36:10 +00:00
* [`/v1/agent/service/deregister/<serviceID>` ](#agent_service_deregister ) : Deregisters a local service
* [`/v1/agent/service/maintenance/<serviceID>` ](#agent_service_maintenance ) : Manages service maintenance mode
2015-01-18 00:28:53 +00:00
### <a name="agent_checks"></a> /v1/agent/checks
2015-02-07 22:36:10 +00:00
This endpoint is used to return all the checks that are registered with
the local agent. These checks were either provided through configuration files
2015-01-18 00:28:53 +00:00
or added dynamically using the HTTP API. It is important to note that the checks
2015-02-07 22:36:10 +00:00
known by the agent may be different from those reported by the Catalog. This is usually
2015-01-18 00:28:53 +00:00
due to changes being made while there is no leader elected. The agent performs active
2015-03-04 15:22:53 +00:00
[anti-entropy ](/docs/internals/anti-entropy.html ), so in most situations everything will
be in sync within a few seconds.
2015-01-18 00:28:53 +00:00
2016-11-25 17:39:08 +00:00
This endpoint is hit with a `GET` and returns a JSON body like this:
2015-01-18 00:28:53 +00:00
```javascript
{
"service:redis": {
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
"ServiceName": "redis"
}
}
```
### <a name="agent_services"></a> /v1/agent/services
2015-04-17 15:43:02 +00:00
This endpoint is used to return all the services that are registered with
2015-02-07 22:36:10 +00:00
the local agent. These services were either provided through configuration files
2015-01-18 00:28:53 +00:00
or added dynamically using the HTTP API. It is important to note that the services
2015-02-07 22:36:10 +00:00
known by the agent may be different from those reported by the Catalog. This is usually
2015-01-18 00:28:53 +00:00
due to changes being made while there is no leader elected. The agent performs active
2015-03-04 15:22:53 +00:00
[anti-entropy ](/docs/internals/anti-entropy.html ), so in most situations everything will
be in sync within a few seconds.
2015-01-18 00:28:53 +00:00
2016-11-25 17:39:08 +00:00
This endpoint is hit with a `GET` and returns a JSON body like this:
2015-01-18 00:28:53 +00:00
```javascript
{
"redis": {
"ID": "redis",
"Service": "redis",
"Tags": null,
"Address": "",
"Port": 8000
}
}
```
### <a name="agent_members"></a> /v1/agent/members
2015-02-07 22:36:10 +00:00
This endpoint is used to return the members the agent sees in the
cluster gossip pool. Due to the nature of gossip, this is eventually consistent: the
results may differ by agent. The strongly consistent view of nodes is
2016-11-25 17:39:08 +00:00
instead provided by `/v1/catalog/nodes` .
2015-01-18 00:28:53 +00:00
2016-11-25 16:00:02 +00:00
For agents running in server mode, providing a `?wan=1` query parameter returns
2015-02-07 22:36:10 +00:00
the list of WAN members instead of the LAN members returned by default.
2015-01-18 00:28:53 +00:00
2016-11-25 17:39:08 +00:00
This endpoint is hit with a `GET` and returns a JSON body like:
2015-01-18 00:28:53 +00:00
```javascript
[
{
"Name": "foobar",
"Addr": "10.1.10.12",
"Port": 8301,
"Tags": {
"bootstrap": "1",
"dc": "dc1",
"port": "8300",
"role": "consul"
},
"Status": 1,
"ProtocolMin": 1,
"ProtocolMax": 2,
"ProtocolCur": 2,
"DelegateMin": 1,
"DelegateMax": 3,
"DelegateCur": 3
}
]
```
### <a name="agent_self"></a> /v1/agent/self
2016-07-29 20:45:25 +00:00
This endpoint is used to return the configuration and member information of the local agent under the `Config` key.
2016-11-25 16:00:02 +00:00
Consul 0.7.0 and later also includes a snapshot of various operating statistics under the `Stats` key. These statistics are intended to help human operators for debugging and may change over time, so this part of the interface should not be consumed programmatically.
2015-01-18 00:28:53 +00:00
2017-01-11 23:44:13 +00:00
Consul 0.7.3 and later also includes a block of user-defined node metadata values under the `Meta` key. These are arbitrary key/value pairs defined in the [node meta ](/docs/agent/options.html#_node_meta ) section of the agent configuration.
2015-01-18 00:28:53 +00:00
It returns a JSON body like this:
```javascript
{
"Config": {
"Bootstrap": true,
"Server": true,
"Datacenter": "dc1",
"DataDir": "/tmp/consul",
"DNSRecursor": "",
"DNSRecursors": [],
"Domain": "consul.",
"LogLevel": "INFO",
2017-01-18 06:20:11 +00:00
"NodeID": "40e4a748-2192-161a-0510-9bf59fe950b5",
2015-01-18 00:28:53 +00:00
"NodeName": "foobar",
"ClientAddr": "127.0.0.1",
"BindAddr": "0.0.0.0",
"AdvertiseAddr": "10.1.10.12",
"Ports": {
"DNS": 8600,
"HTTP": 8500,
"RPC": 8400,
"SerfLan": 8301,
"SerfWan": 8302,
"Server": 8300
},
"LeaveOnTerm": false,
"SkipLeaveOnInt": false,
"StatsiteAddr": "",
"Protocol": 1,
"EnableDebug": false,
"VerifyIncoming": false,
"VerifyOutgoing": false,
"CAFile": "",
"CertFile": "",
"KeyFile": "",
"StartJoin": [],
"UiDir": "",
"PidFile": "",
"EnableSyslog": false,
"RejoinAfterLeave": false
},
2015-07-30 19:02:37 +00:00
"Coord": {
"Adjustment": 0,
"Error": 1.5,
"Vec": [0,0,0,0,0,0,0,0]
},
2015-01-18 00:28:53 +00:00
"Member": {
"Name": "foobar",
"Addr": "10.1.10.12",
"Port": 8301,
"Tags": {
"bootstrap": "1",
"dc": "dc1",
2017-01-18 06:20:11 +00:00
"id": "40e4a748-2192-161a-0510-9bf59fe950b5",
2015-01-18 00:28:53 +00:00
"port": "8300",
"role": "consul",
"vsn": "1",
"vsn_max": "1",
"vsn_min": "1"
},
"Status": 1,
"ProtocolMin": 1,
"ProtocolMax": 2,
"ProtocolCur": 2,
"DelegateMin": 2,
"DelegateMax": 4,
"DelegateCur": 4
2017-01-11 23:44:13 +00:00
},
"Meta": {
"instance_type": "i2.xlarge",
"os_version": "ubuntu_16.04",
2015-01-18 00:28:53 +00:00
}
}
```
2016-11-30 18:29:42 +00:00
### <a name="agent_reload"></a> /v1/agent/reload
Added in Consul 0.7.2, this endpoint is hit with a `PUT` and is used to instruct
the agent to reload its configuration. Any errors encountered during this process
will be returned.
Not all configuration options are reloadable. See the
[Reloadable Configuration ](/docs/agent/options.html#reloadable-configuration )
section on the agent options page for details on which options are supported.
The return code is 200 on success.
2015-01-21 19:15:15 +00:00
### <a name="agent_maintenance"></a> /v1/agent/maintenance
2015-01-18 00:28:53 +00:00
2017-01-31 21:00:27 +00:00
The node maintenance endpoint is hit with a PUT and is used to place the agent
into "maintenance mode". During maintenance mode, the node will be marked as
unavailable and will not be present in DNS or API queries. This API call is
idempotent. Maintenance mode is persistent and will be automatically restored
on agent restart.
2015-01-18 00:28:53 +00:00
2016-11-25 18:25:09 +00:00
The `?enable` flag is required. Acceptable values are either `true` (to enter
2015-02-07 22:36:10 +00:00
maintenance mode) or `false` (to resume normal operation).
2015-01-18 00:28:53 +00:00
2016-11-25 18:25:09 +00:00
The `?reason` flag is optional. If provided, its value should be a text string
2015-02-07 22:36:10 +00:00
explaining the reason for placing the node into maintenance mode. This is simply
to aid human operators. If no reason is provided, a default value will be used instead.
2015-01-21 22:33:01 +00:00
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
2016-11-16 21:45:26 +00:00
### <a name="agent_monitor"></a> /v1/agent/monitor
Added in Consul 0.7.2, This endpoint is hit with a GET and will stream logs from the
local agent until the connection is closed.
The `?loglevel` flag is optional. If provided, its value should be a text string
2016-11-30 18:29:42 +00:00
containing a log level to filter on, such as `info` . If no loglevel is provided,
2016-11-16 21:45:26 +00:00
`info` will be used as a default.
The return code is 200 on success.
2015-01-18 00:28:53 +00:00
### <a name="agent_join"></a> /v1/agent/join/\<address\>
2016-11-25 17:39:08 +00:00
This endpoint is hit with a `GET` and is used to instruct the agent to attempt to
2016-11-25 18:25:09 +00:00
connect to a given address. For agents running in server mode, providing a `?wan=1`
2015-01-18 00:28:53 +00:00
query parameter causes the agent to attempt to join using the WAN pool.
2015-02-07 22:36:10 +00:00
The return code is 200 on success.
2015-01-18 00:28:53 +00:00
2016-11-30 18:29:42 +00:00
### <a name="agent_leave"></a> /v1/agent/leave
Added in Consul 0.7.2, this endpoint is hit with a `PUT` and is used to trigger a
graceful leave and shutdown of the agent. It is used to ensure other nodes see the
agent as "left" instead of "failed". Nodes that leave will not attempt to re-join
the cluster on restarting with a snapshot.
For nodes in server mode, the node is removed from the Raft peer set in a graceful
manner. This is critical, as in certain situations a non-graceful leave can affect
cluster availability.
The return code is 200 on success.
2015-01-18 00:28:53 +00:00
### <a name="agent_force_leave"></a> /v1/agent/force-leave/\<node\>
2016-11-30 18:29:42 +00:00
This endpoint is hit with a `PUT` and is used to instruct the agent to force a node
into the `left` state. If a node fails unexpectedly, then it will be in a `failed`
state. Once in the `failed` state, Consul will attempt to reconnect, and the
services and checks belonging to that node will not be cleaned up. Forcing a node
into the `left` state allows its old entries to be removed.
2015-01-18 00:28:53 +00:00
The endpoint always returns 200.
### <a name="agent_check_register"></a> /v1/agent/check/register
The register endpoint is used to add a new check to the local agent.
There is more documentation on checks [here ](/docs/agent/checks.html ).
2015-07-27 00:53:52 +00:00
Checks may be of script, HTTP, TCP, or TTL type. The agent is responsible for
managing the status of the check and keeping the Catalog in sync.
2015-01-18 00:28:53 +00:00
2016-11-25 17:39:08 +00:00
The register endpoint expects a JSON request body to be `PUT` . The request
2015-01-18 00:28:53 +00:00
body must look like:
```javascript
{
"ID": "mem",
"Name": "Memory utilization",
"Notes": "Ensure we don't oversubscribe memory",
2016-10-04 13:40:53 +00:00
"DeregisterCriticalServiceAfter": "90m",
2015-01-18 00:28:53 +00:00
"Script": "/usr/local/bin/check_mem.py",
2015-11-18 15:40:02 +00:00
"DockerContainerID": "f972c95ebf0e",
"Shell": "/bin/bash",
2015-01-18 00:28:53 +00:00
"HTTP": "http://example.com",
2015-07-27 00:53:52 +00:00
"TCP": "example.com:22",
2015-01-18 00:28:53 +00:00
"Interval": "10s",
2016-11-03 20:17:30 +00:00
"TTL": "15s",
"TLSSkipVerify": true
2015-01-18 00:28:53 +00:00
}
```
2015-07-27 00:53:52 +00:00
The `Name` field is mandatory, as is one of `Script` , `HTTP` , `TCP` or `TTL` .
`Script` , `TCP` and `HTTP` also require that `Interval` be set.
2015-01-18 00:28:53 +00:00
If an `ID` is not provided, it is set to `Name` . You cannot have duplicate
2015-02-07 22:36:10 +00:00
`ID` entries per agent, so it may be necessary to provide an `ID` .
The `Notes` field is not used internally by Consul and is meant to be human-readable.
2015-01-18 00:28:53 +00:00
2016-08-16 16:27:20 +00:00
In Consul 0.7 and later, checks that are associated with a service may also contain
an optional `DeregisterCriticalServiceAfter` field, which is a timeout in the same Go
time format as `Interval` and `TTL` . If a check is in the critical state for more than
this configured value, then its associated service (and all of its associated checks)
2016-08-16 07:05:55 +00:00
will automatically be deregistered. The minimum timeout is 1 minute, and the
2016-08-16 19:52:30 +00:00
process that reaps critical services runs every 30 seconds, so it may take slightly
2016-08-16 07:05:55 +00:00
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.
2015-01-18 00:28:53 +00:00
If a `Script` is provided, the check type is a script, and Consul will
evaluate the script every `Interval` to update the status.
2015-11-18 15:40:02 +00:00
If a `DockerContainerID` is provided, 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.
2016-11-25 17:39:08 +00:00
An `HTTP` check will perform an HTTP `GET` request against the value of
2016-11-25 16:00:02 +00:00
`HTTP` (expected to be a URL) every `Interval` . If the response is any
2016-11-25 18:25:09 +00:00
`2xx` code, the check is `passing` . If the response is `429 Too Many
2016-11-25 16:00:02 +00:00
Requests`, the check is `warning` . Otherwise, the check is `critical` .
HTTP checks also support SSL. By default, a valid SSL certificate is
2016-11-25 18:25:09 +00:00
expected. Certificate verification can be controlled using the
2016-11-25 16:00:02 +00:00
`TLSSkipVerify` .
2015-01-18 00:28:53 +00:00
2016-11-25 16:00:02 +00:00
If `TLSSkipVerify` is set to `true` , certificate verification will be
disabled. By default, certificate verification is enabled.
2016-11-03 20:17:30 +00:00
A `TCP` check will perform an TCP connection attempt against the value of `TCP`
2016-11-25 16:00:02 +00:00
(expected to be an IP or hostname plus port combination) every `Interval` . If the
2016-11-25 18:25:09 +00:00
connection attempt is successful, the check is `passing` . If the connection
attempt is unsuccessful, the check is `critical` . In the case of a hostname
2015-07-27 00:53:52 +00:00
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.
2016-11-25 16:00:02 +00:00
If a `TTL` type is used, then the TTL update endpoint must be used
periodically to update the state of the check.
2015-01-18 00:28:53 +00:00
2015-05-28 20:09:33 +00:00
The `ServiceID` field can be provided to associate the registered check with an
existing service provided by the agent.
The `Status` field can be provided to specify the initial state of the health
check.
2015-04-21 03:56:26 +00:00
2015-04-28 21:26:22 +00:00
This endpoint supports [ACL tokens ](/docs/internals/acl.html ). If the query
string includes a `?token=<token-id>` , the registration will use the provided
token to authorize the request. The token is also persisted in the agent's
local configuration to enable periodic
2016-01-14 00:32:30 +00:00
[anti-entropy ](/docs/internals/anti-entropy.html ) syncs and seamless agent
2015-04-28 21:26:22 +00:00
restarts.
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
### <a name="agent_check_deregister"></a> /v1/agent/check/deregister/\<checkId\>
2015-02-07 22:36:10 +00:00
This endpoint is used to remove a check from the local agent.
The `CheckID` must be passed on the path. The agent will take care
of deregistering the check from the Catalog.
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
### <a name="agent_check_pass"></a> /v1/agent/check/pass/\<checkId\>
This endpoint is used with a check that is of the [TTL type ](/docs/agent/checks.html ).
2016-11-25 17:39:08 +00:00
When this endpoint is accessed via a `GET` , the status of the check is set to `passing`
2015-01-18 00:28:53 +00:00
and the TTL clock is reset.
2016-11-25 16:00:02 +00:00
The optional `?note=` query parameter can be used to associate a
human-readable message with the status of the check. This will be passed
through to the check's `Output` field in the check endpoints.
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
### <a name="agent_check_warn"></a> /v1/agent/check/warn/\<checkId\>
This endpoint is used with a check that is of the [TTL type ](/docs/agent/checks.html ).
2016-11-25 17:39:08 +00:00
When this endpoint is accessed via a `GET` , the status of the check is set to `warning` ,
2015-01-18 00:28:53 +00:00
and the TTL clock is reset.
2016-11-25 16:00:02 +00:00
The optional `?note=` query parameter can be used to associate a
human-readable message with the status of the check. This will be passed
through to the check's `Output` field in the check endpoints.
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
### <a name="agent_check_fail"></a> /v1/agent/check/fail/\<checkId\>
2016-11-25 16:00:02 +00:00
This endpoint is used with a check that is of the [TTL
2016-11-25 18:25:09 +00:00
type](/docs/agent/checks.html). When this endpoint is accessed via a
2016-11-25 17:39:08 +00:00
`GET` , the status of the check is set to `critical` , and the TTL clock is
2016-11-25 16:00:02 +00:00
reset.
2015-01-18 00:28:53 +00:00
2016-11-25 16:00:02 +00:00
The optional `?note=` query parameter can be used to associate a
human-readable message with the status of the check. This will be passed
through to the check's `Output` field in the check endpoints.
2016-03-03 01:08:06 +00:00
The return code is 200 on success.
### <a name="agent_check_update"></a> /v1/agent/check/update/\<checkId\>
This endpoint is used with a check that is of the [TTL type ](/docs/agent/checks.html ).
2016-11-25 17:39:08 +00:00
When this endpoint is accessed with a `PUT` , the status and output of the check are
2016-03-03 01:08:06 +00:00
updated and the TTL clock is reset.
This endpoint expects a JSON request body to be put. The request body must look like:
```javascript
{
"Status": "passing",
"Output": "curl reported a failure:\n\n..."
}
```
2016-11-25 16:00:02 +00:00
The `Status` field is mandatory, and must be set to `passing` ,
`warning` , or `critical` .
2016-03-03 01:08:06 +00:00
2016-11-25 16:00:02 +00:00
`Output` is an optional field that will associate a human-readable
message with the status of the check, such as the output of the checking
script or process. This will be truncated if it exceeds 4KB in size.
This will be passed through to the check's `Output` field in the check
endpoints.
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
### <a name="agent_service_register"></a> /v1/agent/service/register
2016-11-25 16:00:02 +00:00
The register endpoint is used to add a new service, with an optional
health check, to the local agent. There is more documentation on
2016-11-25 18:25:09 +00:00
services [here ](/docs/agent/services.html ). The agent is responsible
2016-11-25 16:00:02 +00:00
for managing the status of its local services, and for sending updates
about its local services to the servers to keep the global Catalog in
sync.
2015-01-18 00:28:53 +00:00
2016-11-25 17:39:08 +00:00
The register endpoint expects a JSON request body to be `PUT` . The request
2015-01-18 00:28:53 +00:00
body must look like:
```javascript
{
"ID": "redis1",
"Name": "redis",
"Tags": [
2016-11-25 16:00:02 +00:00
"primary",
2015-01-18 00:28:53 +00:00
"v1"
],
"Address": "127.0.0.1",
"Port": 8000,
2016-11-16 21:45:26 +00:00
"EnableTagOverride": false,
2015-01-18 00:28:53 +00:00
"Check": {
2016-08-16 07:05:55 +00:00
"DeregisterCriticalServiceAfter": "90m",
2015-01-18 00:28:53 +00:00
"Script": "/usr/local/bin/check_redis.py",
"HTTP": "http://localhost:5000/health",
"Interval": "10s",
"TTL": "15s"
}
}
```
2016-11-25 18:25:09 +00:00
The `Name` field is mandatory. If an `ID` is not provided, it is set to
`Name` . You cannot have duplicate `ID` entries per agent, so it may be
2016-11-25 16:00:02 +00:00
necessary to provide an ID in the case of a collision.
2015-02-07 22:43:43 +00:00
2016-07-22 17:21:07 +00:00
`Tags` , `Address` , `Port` , `Check` and `EnableTagOverride` are optional.
2015-02-07 22:36:10 +00:00
2016-04-20 17:16:06 +00:00
If `Address` is not provided or left empty, then the agent's address will be used
as the address for the service during DNS queries. When querying for services using
HTTP endpoints such as [service health ](/docs/agent/http/health.html#health_service )
or [service catalog ](/docs/agent/http/catalog.html#catalog_service ) and encountering
an empty `Address` field for a service, use the `Address` field of the agent node
associated with that instance of the service, which is returned alongside the service
information.
2015-02-07 22:36:10 +00:00
2016-11-25 16:00:02 +00:00
If `Check` is provided, only one of `Script` , `HTTP` , `TCP` or `TTL`
should be specified. `Script` and `HTTP` also require `Interval` . The
2016-12-26 20:32:20 +00:00
created check will be named `service:<ServiceId>` . The `Status` field
can be provided to specify the initial state of the health check.
2016-11-25 16:00:02 +00:00
In Consul 0.7 and later, checks that are associated with a service may
also contain an optional `DeregisterCriticalServiceAfter` field, which
is a timeout in the same [Go time format ](https://golang.org/pkg/time/ )
as `Interval` and `TTL` . 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 is much, much longer than any expected
2016-08-16 07:05:55 +00:00
recoverable outage for the given service.
2015-02-07 22:43:43 +00:00
There is more information about checks [here ](/docs/agent/checks.html ).
2015-01-18 00:28:53 +00:00
2016-11-25 16:00:02 +00:00
The `EnableTagOverride` option can be specified to disable the
anti-entropy feature for this service's tags. If `EnableTagOverride` is
set to `true` then external agents can update this service in the
[catalog ](/docs/agent/http/catalog.html ) and modify the tags. Subsequent
local sync operations by this agent will ignore the updated tags. For
instance, if an external agent modified both the tags and the port for
this service and `EnableTagOverride` was set to `true` then after the
next sync cycle the service's port would revert to the original value
but the tags would maintain the updated value. As a counter example, if
an external agent modified both the tags and port for this service and
`EnableTagOverride` was set to `false` then after the next sync cycle
the service's port _and_ the tags would revert to the original value and
all modifications would be lost.
It's important to note that this applies only to the locally registered
service. If you have multiple nodes all registering the same service
their `EnableTagOverride` configuration and all other service
configuration items are independent of one another. Updating the tags
for the service registered on one node is independent of the same
2016-11-25 18:25:09 +00:00
service (by name) registered on another node. If `EnableTagOverride` is
not specified the default value is `false` . See [anti-entropy
2016-11-25 16:00:02 +00:00
syncs](/docs/internals/anti-entropy.html) for more info.
2016-07-22 17:21:07 +00:00
2015-04-28 21:26:22 +00:00
This endpoint supports [ACL tokens ](/docs/internals/acl.html ). If the query
string includes a `?token=<token-id>` , the registration will use the provided
token to authorize the request. The token is also persisted in the agent's
local configuration to enable periodic
2016-01-14 00:32:30 +00:00
[anti-entropy ](/docs/internals/anti-entropy.html ) syncs and seamless agent
2015-04-28 21:26:22 +00:00
restarts.
2015-01-18 00:28:53 +00:00
The return code is 200 on success.
### <a name="agent_service_deregister"></a> /v1/agent/service/deregister/\<serviceId\>
The deregister endpoint is used to remove a service from the local agent.
2016-11-25 16:00:02 +00:00
The `ServiceID` must be passed after the slash. The agent will take care
2015-01-18 00:28:53 +00:00
of deregistering the service with the Catalog. If there is an associated
check, that is also deregistered.
The return code is 200 on success.
### <a name="agent_service_maintenance"></a> /v1/agent/service/maintenance/\<serviceId\>
The service maintenance endpoint allows placing a given service into
"maintenance mode". During maintenance mode, the service will be marked as
2015-02-07 22:36:10 +00:00
unavailable and will not be present in DNS or API queries. This API call is
2015-01-18 00:28:53 +00:00
idempotent. Maintenance mode is persistent and will be automatically restored
2016-11-25 17:39:08 +00:00
on agent restart. The maintenance endpoint expects a `PUT` request.
2015-01-18 00:28:53 +00:00
2016-11-25 18:25:09 +00:00
The `?enable` flag is required. Acceptable values are either `true` (to enter
2015-02-07 22:36:10 +00:00
maintenance mode) or `false` (to resume normal operation).
2015-01-18 00:28:53 +00:00
2016-11-25 18:25:09 +00:00
The `?reason` flag is optional. If provided, its value should be a text string
2015-02-07 22:36:10 +00:00
explaining the reason for placing the service into maintenance mode. This is simply
to aid human operators. If no reason is provided, a default value will be used instead.
2015-01-21 22:33:01 +00:00
2015-01-18 00:28:53 +00:00
The return code is 200 on success.