Agent HTTP API
The /agent
endpoints are used to interact with the local Nomad agent.
List Members
This endpoint queries the agent for the known peers in the gossip pool. This endpoint is only applicable to servers. Due to the nature of gossip, this is eventually consistent.
Method | Path | Produces |
---|---|---|
GET | /agent/members | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | node:read |
Sample Request
Sample Response
List Servers
This endpoint lists the known server nodes. The servers
endpoint is used to
query an agent in client mode for its list of known servers. Client nodes
register themselves with these server addresses so that they may dequeue work.
The servers endpoint can be used to keep this configuration up to date if there
are changes in the cluster.
Method | Path | Produces |
---|---|---|
GET | /agent/servers | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:read |
Sample Request
Sample Response
Update Servers
This endpoint updates the list of known servers to the provided list. This replaces all previous server addresses with the new list.
Method | Path | Produces |
---|---|---|
POST | /agent/servers | (empty body) |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:write |
Parameters
address
(string: <required>)
- Specifies the list of addresses in the formatip:port
. This is specified as a query string.
Sample Request
Query Self
This endpoint queries the state of the target agent (self).
Method | Path | Produces |
---|---|---|
GET | /agent/self | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:read |
Sample Request
Sample Response
Join Agent
This endpoint introduces a new member to the gossip pool. This endpoint is only eligible for servers.
Method | Path | Produces |
---|---|---|
POST | /agent/join | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | none |
Parameters
address
(string: <required>)
- Specifies the address to join in theip:port
format. This is provided as a query parameter and may be specified multiple times to join multiple servers.
Sample Request
Sample Response
Force Leave Agent
This endpoint forces a member of the gossip pool from the "failed"
state to
the "left"
state. This allows the consensus protocol to remove the peer and
stop attempting replication. This is only applicable for servers.
Method | Path | Produces |
---|---|---|
POST | /agent/force-leave | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:write |
Parameters
node
(string: <required>)
- Specifies the name of the node to force leave.
Sample Request
Health
This endpoint returns whether or not the agent is healthy. When using Consul it is the endpoint Nomad will register for its own health checks.
When the agent is unhealthy 500 will be returned along with JSON response containing an error message.
Method | Path | Produces |
---|---|---|
GET | /agent/health | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | none |
Sample Request
Sample Response
Host
This endpoint returns data about the agent's host environment from the
perspective of the agent. It is included in the archive produced by
nomad operator debug. Known sensitive environment variables are shown as
<redacted>
, but the response may still contain sensitive
information.
Method | Path | Produces |
---|---|---|
GET | /agent/host | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:read |
Parameters
server_id
(string: <optional>)
- Specify the server name for targeting.node_id
(string: <optional>)
- Specify the client node id for targeting.
Sample Request
Sample Response
Stream Logs
This endpoint streams logs from the local agent until the connection is closed
Method | Path | Produces |
---|---|---|
GET | /agent/monitor | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:read |
Parameters
log_level
(string: "info")
- Specifies a text string containing a log level to filter on, such asinfo
. Possible values includetrace
,debug
,info
,warn
,error
log_json
(bool: false)
- Specifies if the log format for streamed logs should be JSON.node_id
(string: "a57b2adb-1a30-2dda-8df0-25abb0881952")
- Specifies a text string containing a node-id to target for streaming.server_id
(string: "server1.global")
- Specifies a text string containing a server name or "leader" to target a specific remote server or leader for streaming.plain
(bool: false)
- Specifies if the response should be JSON or plaintext
Sample Request
Sample Response
Field Reference
The return value is a stream of frames. These frames contain the following fields:
Data
- A base64 encoding of the bytes being streamed.FileEvent
- An event that could cause a change in the streams position. The possible value for this endpoint is "log".Offset
- Offset is the offset into the stream.
Agent Runtime Profiles
This endpoint is the equivalent of Go's /debug/pprof endpoint but is protected by ACLs and supports remote forwarding to a client node or server. See the Golang documentation for a list of available profiles.
Method | Path | Produces |
---|---|---|
GET | /agent/pprof/cmdline | text/plain |
GET | /agent/pprof/profile | application/octet-stream |
GET | /agent/pprof/trace | application/octet-stream |
GET | /agent/pprof/<pprof profile> | application/octet-stream |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:write |
Default Behavior
This endpoint is enabled whenever ACLs are enabled. Due to the potentially
sensitive nature of data contained in profiles, as well as their significant
performance impact, the agent/pprof endpoint is protected by a high level ACL:
agent:write
. For these reasons its recommended to leave enable_debug
unset and only use the ACL-protected endpoints.
The following table explains when each endpoint is available:
Endpoint | enable_debug | ACLs | Available? |
---|---|---|---|
/v1/agent/pprof | unset | n/a | no |
/v1/agent/pprof | true | n/a | yes |
/v1/agent/pprof | false | n/a | no |
/v1/agent/pprof | unset | off | no |
/v1/agent/pprof | unset | on | yes |
/v1/agent/pprof | true | off | yes |
/v1/agent/pprof | false | on | yes |
Parameters
node_id
(string: "a57b2adb-1a30-2dda-8df0-25abb0881952")
- Specifies a text string containing a Node ID to target for profiling.server_id
(string: "server1.global")
- Specifies a text string containing a Server ID, name, orleader
to target a specific remote server or leader for profiling.seconds
(int: 3)
- Specifies the amount of time to run a profile or trace request for.debug
(int: 1)
- Specifies if a given pprof profile should be returned as human readable plain text instead of the pprof binary format. Defaults to 0, setting to 1 enables human readable plain text.
Sample Request
Fetch all scheduler worker's status
The /agent/schedulers
endpoint allow Nomad operators to inspect the state of
a Nomad server agent's scheduler workers.
Method | Path | Produces |
---|---|---|
GET | /agent/schedulers | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:read |
Parameters
This endpoint accepts no additional parameters.
Sample Request
Sample Response
Read scheduler worker configuration
This endpoint returns data about the agent's scheduler configuration from the perspective of the agent. This is only applicable for servers.
Method | Path | Produces |
---|---|---|
GET | /agent/schedulers/config | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:read |
Parameters
This endpoint accepts no additional parameters.
Sample Request
Sample Response
Update scheduler worker configuration
This allows a Nomad operator to modify the server's running scheduler
configuration, which will remain in effect until another update or until the
node is restarted. For durable changes to this value, set the corresponding
values—num_schedulers
and enabled_schedulers
—in the node's
configuration file. The response contains the configuration after attempting
to apply the provided values. This is only applicable for servers.
Method | Path | Produces |
---|---|---|
PUT | /agent/schedulers/config | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | agent:write |
Sample Payload
Sample Request
Sample Response