Client HTTP API
The /client
endpoints are used to interact with the Nomad clients.
Since Nomad 0.8.0, both a client and server can handle client endpoints. This is particularly useful for when a direct connection to a client is not possible due to the network configuration. For high volume access to the client endpoints, particularly endpoints streaming file contents, direct access to the node should be preferred as it avoids adding additional load to the servers.
When accessing the endpoints via the server, if the desired node is ambiguous
based on the URL, an additional ?node_id
query parameter must be provided to
disambiguate.
Read Stats
This endpoint queries the actual resources consumed on a node. The API endpoint is hosted by the Nomad client and requests have to be made to the nomad client whose resource usage metrics are of interest.
Method | Path | Produces |
---|---|---|
GET | /client/stats | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | node:read |
Parameters
node_id
(string: <optional>)
- Specifies the node to query. This is required when the endpoint is being accessed via a server. This is specified as part of the URL. Note, this must be the full node ID, not the short 8-character one. This is specified as part of the path.
Sample Request
Sample Response
Read Allocation Statistics
The client allocation
endpoint is used to query the actual resources consumed
by an allocation.
Method | Path | Produces |
---|---|---|
GET | /client/allocation/:alloc_id/stats | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-job |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.
Sample Request
Sample Response
Read File
This endpoint reads the contents of a file in an allocation directory.
Method | Path | Produces |
---|---|---|
GET | /client/fs/cat/:alloc_id | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-fs |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.path
(string: "/")
- Specifies the path of the file to read, relative to the root of the allocation directory.
Sample Request
Sample Response
Read File at Offset
This endpoint reads the contents of a file in an allocation directory at a particular offset and limit.
Method | Path | Produces |
---|---|---|
GET | /client/fs/readat/:alloc_id | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-fs |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.path
(string: "/")
- Specifies the path of the file to read, relative to the root of the allocation directory.offset
(int: <required>)
- Specifies the byte offset from where content will be read.limit
(int: <required>)
- Specifies the number of bytes to read from the offset.
Sample Request
Sample Response
Stream File
This endpoint streams the contents of a file in an allocation directory.
Method | Path | Produces |
---|---|---|
GET | /client/fs/stream/:alloc_id | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-fs |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.path
(string: "/")
- Specifies the path of the file to read, relative to the root of the allocation directory.follow
(bool: true)
- Specifies whether to tail the file.offset
(int: <required>)
- Specifies the byte offset from where content will be read.origin
(string: "start|end")
- Applies the relative offset to either the start or end of the file.
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 values are "file deleted" and "file truncated".Offset
- Offset is the offset into the stream.File
- The name of the file being streamed.
Stream Logs
This endpoint streams a task's stderr/stdout logs.
Method | Path | Produces |
---|---|---|
GET | /client/fs/logs/:alloc_id | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-logs or namespace:read-fs |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.task
(string: <required>)
- Specifies the name of the task inside the allocation to stream logs from.follow
(bool: false)
- Specifies whether to tail the logs.type
(string: "stderr|stdout")
- Specifies the stream to stream.offset
(int: 0)
- Specifies the offset to start streaming from.origin
(string: "start|end")
- Specifies either "start" or "end" and applies the offset relative to either the start or end of the logs respectively. Defaults to "start".plain
(bool: false)
- Return just the plain text without framing. This can be useful when viewing logs in a browser.
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 values are "file deleted" and "file truncated".Offset
- Offset is the offset into the stream.File
- The name of the file being streamed.
List Files
This endpoint lists files in an allocation directory.
Method | Path | Produces |
---|---|---|
GET | /client/fs/ls/:alloc_id | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-fs |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.path
(string: "/")
- Specifies the path of the file to read, relative to the root of the allocation directory.
Sample Request
Sample Response
Stat File
This endpoint stats a file in an allocation.
Method | Path | Produces |
---|---|---|
GET | /client/fs/stat/:alloc_id | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-fs |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.path
(string: "/")
- Specifies the path of the file to read, relative to the root of the allocation directory.
Sample Request
Sample Response
GC Allocation
This endpoint forces a garbage collection of a particular, stopped allocation on a node. Note that the allocation will still exist on the server and appear in server responses.
Method | Path | Produces |
---|---|---|
GET | /client/allocation/:alloc_id/gc | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job |
Parameters
:alloc_id
(string: <required>)
- Specifies the allocation ID to query. This is specified as part of the URL. Note, this must be the full allocation ID, not the short 8-character one. This is specified as part of the path.
Sample Request
GC All Allocation
This endpoint forces a garbage collection of all stopped allocations on a node.
Method | Path | Produces |
---|---|---|
GET | /client/gc | text/plain |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | node:write |
Parameters
node_id
(string: <optional>)
- Specifies the node to target. This is required when the endpoint is being accessed via a server. This is specified as part of the URL. Note, this must be the full node ID, not the short 8-character one. This is specified as part of the path.
Sample Request