7.9 KiB
layout | page_title | sidebar_current | description |
---|---|---|---|
http | HTTP API: /v1/client/fs | docs-http-client-fs | The '/v1/client/fs` endpoints are used to read the contents of an allocation directory. |
/v1/client/fs
The client fs
endpoints are used to read the contents of files and
directories inside an allocation directory. The API endpoints are hosted by the
Nomad client and requests have to be made to the Client where the particular
allocation was placed.
GET
- Description
- Read contents of a file in an allocation directory.
- Method
- GET
- URL
- `/v1/client/fs/cat/`
- Parameters
-
- path required The path relative to the root of the allocation directory. It defaults to `/`
- Returns
-
```
... 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 # Server started, Redis version 3.2.1 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 * The server is now ready to accept connections on port 6379 ... ```
- Description
- Read contents of a file in an allocation directory at a particular offset.
- Method
- GET
- URL
- `/v1/client/fs/readat/`
- Parameters
-
- path required The path relative to the root of the allocation directory. It defaults to `/`
- offset required The byte offset from where content is going to be read.
- limit required The number of bytes to read from the offset.
- Returns
-
```
... 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 # Server started, Redis version 3.2.1 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 * The server is now ready to accept connections on port 6379 ... ```
- Description
- Stream contents of a file in an allocation directory.
- Method
- GET
- URL
- `/v1/client/fs/stream/`
- Parameters
-
- path required The path relative to the root of the allocation directory. It defaults to `/`
- offset The offset to start streaming from. Defaults to 0.
- origin Origin can be either "start" or "end" and applies the offset relative to either the start or end of the file respectively. Defaults to "start".
- Returns
-
```
... { "File":"alloc/logs/redis.stdout.0", "Offset":3604480 "Data": "NTMxOTMyCjUzMTkzMwo1MzE5MzQKNTMx..." } { "File":"alloc/logs/redis.stdout.0", "FileEvent": "file deleted" } ```
- Field Reference
-
The return value is a stream of frames. These frames contain the following
fields:
<ul> <li> <span class="param">Data</span> A base64 encoding of the bytes being streamed. </li> <li> <span class="param">FileEvent</span> An event that could cause a change in the streams position. The possible values are "file deleted" and "file truncated". </li> <li> <span class="param">Offset</span> Offset is the offset into the stream. </li> <li> <span class="param">File</span> The name of the file being streamed. </li> </ul>
- Description
- Stream a task's stdout/stderr logs.
- Method
- GET
- URL
- `/v1/client/fs/logs/`
- Parameters
-
- task required The name of the task inside the allocation to stream logs from.
- follow required A boolean of whether to follow logs.
- type Either, "stdout" or "stderr", defaults to "stdout" if omitted.
- offset The offset to start streaming from. Defaults to 0.
- origin Origin can be either "start" or "end" and applies the offset relative to either the start or end of the logs respectively. Defaults to "start".
- plain A boolean of whether to return just the plain text without framing. This can be usef when viewing logs in a browser.
- Returns
-
```
... { "File":"alloc/logs/redis.stdout.0", "Offset":3604480 "Data": "NTMxOTMyCjUzMTkzMwo1MzE5MzQKNTMx..." } { "File":"alloc/logs/redis.stdout.0", "FileEvent": "file deleted" } ```
- Field Reference
-
The return value is a stream of frames. These frames contain the following
fields:
<ul> <li> <span class="param">Data</span> A base64 encoding of the bytes being streamed. </li> <li> <span class="param">FileEvent</span> An event that could cause a change in the streams position. The possible values are "file deleted" and "file truncated". </li> <li> <span class="param">Offset</span> Offset is the offset into the stream. </li> <li> <span class="param">File</span> The name of the file being streamed. </li> </ul>
- Description
- List files in an allocation directory.
- Method
- GET
- URL
- `/v1/client/fs/ls/`
- Parameters
-
- path required The path relative to the root of the allocation directory. It defaults to `/`, the root of the allocation directory.
- Returns
-
```javascript [ { "Name": "alloc", "IsDir": true, "Size": 4096, "FileMode": "drwxrwxr-x", "ModTime": "2016-03-15T15:40:00.414236712-07:00" }, { "Name": "redis", "IsDir": true, "Size": 4096, "FileMode": "drwxrwxr-x", "ModTime": "2016-03-15T15:40:56.810238153-07:00" } ] ```
- Description
- Stat a file in an allocation directory.
- Method
- GET
- URL
- `/v1/client/fs/stat/`
- Parameters
-
- path required The path of the file relative to the root of the allocation directory.
- Returns
-
```javascript { "Name": "redis-syslog-collector.out", "IsDir": false, "Size": 96, "FileMode": "-rw-rw-r--", "ModTime": "2016-03-15T15:40:56.822238153-07:00" } ```