github.com/mattyr/nomad@v0.3.3-0.20160919021406-3485a065154a/website/source/docs/http/client-fs.html.md (about) 1 --- 2 layout: "http" 3 page_title: "HTTP API: /v1/client/fs" 4 sidebar_current: "docs-http-client-fs" 5 description: |- 6 The '/v1/client/fs` endpoints are used to read the contents of an allocation 7 directory. 8 --- 9 10 # /v1/client/fs 11 12 The client `fs` endpoints are used to read the contents of files and 13 directories inside an allocation directory. The API endpoints are hosted by the 14 Nomad client and requests have to be made to the Client where the particular 15 allocation was placed. 16 17 ## GET 18 19 <dl> 20 <dt>Description</dt> 21 <dd> 22 Read contents of a file in an allocation directory. 23 </dd> 24 25 <dt>Method</dt> 26 <dd>GET</dd> 27 28 <dt>URL</dt> 29 <dd>`/v1/client/fs/cat/<Allocation-ID>`</dd> 30 31 <dt>Parameters</dt> 32 <dd> 33 <ul> 34 <li> 35 <span class="param">path</span> 36 <span class="param-flags">required</span> 37 The path relative to the root of the allocation directory. It 38 defaults to `/` 39 </li> 40 </ul> 41 </dd> 42 43 <dt>Returns</dt> 44 <dd> 45 46 ``` 47 ... 48 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 # Server started, Redis version 3.2.1 49 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 * The server is now ready to accept connections on port 6379 50 ... 51 ``` 52 53 </dd> 54 55 </dl> 56 57 <dl> 58 <dt>Description</dt> 59 <dd> 60 Read contents of a file in an allocation directory at a particular offset. 61 </dd> 62 63 <dt>Method</dt> 64 <dd>GET</dd> 65 66 <dt>URL</dt> 67 <dd>`/v1/client/fs/readat/<Allocation-ID>`</dd> 68 69 <dt>Parameters</dt> 70 <dd> 71 <ul> 72 <li> 73 <span class="param">path</span> 74 <span class="param-flags">required</span> 75 The path relative to the root of the allocation directory. It 76 defaults to `/` 77 </li> 78 </ul> 79 <ul> 80 <li> 81 <span class="param">offset</span> 82 <span class="param-flags">required</span> 83 The byte offset from where content is going to be read. 84 </li> 85 </ul> 86 <ul> 87 <li> 88 <span class="param">limit</span> 89 <span class="param-flags">required</span> 90 The number of bytes to read from the offset. 91 </li> 92 </ul> 93 94 </dd> 95 96 <dt>Returns</dt> 97 <dd> 98 99 ``` 100 ... 101 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 # Server started, Redis version 3.2.1 102 07:49 docker/3e8f0f4a67c2[924]: 1:M 22 Jun 21:07:49.110 * The server is now ready to accept connections on port 6379 103 ... 104 ``` 105 106 </dd> 107 108 </dl> 109 110 111 <dl> 112 <dt>Description</dt> 113 <dd> 114 Stream contents of a file in an allocation directory. 115 </dd> 116 117 <dt>Method</dt> 118 <dd>GET</dd> 119 120 <dt>URL</dt> 121 <dd>`/v1/client/fs/stream/<Allocation-ID>`</dd> 122 123 <dt>Parameters</dt> 124 <dd> 125 <ul> 126 <li> 127 <span class="param">path</span> 128 <span class="param-flags">required</span> 129 The path relative to the root of the allocation directory. It 130 defaults to `/` 131 </li> 132 <li> 133 <span class="param">offset</span> 134 The offset to start streaming from. Defaults to 0. 135 </li> 136 <li> 137 <span class="param">origin</span> 138 Origin can be either "start" or "end" and applies the offset relative to 139 either the start or end of the file respectively. Defaults to "start". 140 </li> 141 </ul> 142 </dd> 143 144 <dt>Returns</dt> 145 <dd> 146 147 ``` 148 ... 149 { 150 "File":"alloc/logs/redis.stdout.0", 151 "Offset":3604480 152 "Data": "NTMxOTMyCjUzMTkzMwo1MzE5MzQKNTMx..." 153 } 154 { 155 "File":"alloc/logs/redis.stdout.0", 156 "FileEvent": "file deleted" 157 } 158 ``` 159 160 </dd> 161 162 163 <dt>Field Reference</dt> 164 <dd> 165 The return value is a stream of frames. These frames contain the following 166 fields: 167 168 <ul> 169 <li> 170 <span class="param">Data</span> 171 A base64 encoding of the bytes being streamed. 172 </li> 173 <li> 174 <span class="param">FileEvent</span> 175 An event that could cause a change in the streams position. The possible 176 values are "file deleted" and "file truncated". 177 </li> 178 <li> 179 <span class="param">Offset</span> 180 Offset is the offset into the stream. 181 </li> 182 <li> 183 <span class="param">File</span> 184 The name of the file being streamed. 185 </li> 186 </ul> 187 </dd> 188 </dl> 189 190 <a id="logs"></a> 191 192 <dl> 193 <dt>Description</dt> 194 <dd> 195 Stream a tasks stdout/stderr logs. 196 </dd> 197 198 <dt>Method</dt> 199 <dd>GET</dd> 200 201 <dt>URL</dt> 202 <dd>`/v1/client/fs/logs/<Allocation-ID>`</dd> 203 204 <dt>Parameters</dt> 205 <dd> 206 <ul> 207 <li> 208 <span class="param">task</span> 209 <span class="param-flags">required</span> 210 The name of the task inside the allocation to stream logs from. 211 </li> 212 <li> 213 <span class="param">follow</span> 214 <span class="param-flags">required</span> 215 A boolean of whether to follow logs. 216 </li> 217 <li> 218 <span class="param">type</span> 219 Either, "stdout" or "stderr", defaults to "stdout" if omitted. 220 </li> 221 <li> 222 <span class="param">offset</span> 223 The offset to start streaming from. Defaults to 0. 224 </li> 225 <li> 226 <span class="param">origin</span> 227 Origin can be either "start" or "end" and applies the offset relative to 228 either the start or end of the logs respectively. Defaults to "start". 229 </li> 230 </ul> 231 </dd> 232 233 <dt>Returns</dt> 234 <dd> 235 236 ``` 237 ... 238 { 239 "File":"alloc/logs/redis.stdout.0", 240 "Offset":3604480 241 "Data": "NTMxOTMyCjUzMTkzMwo1MzE5MzQKNTMx..." 242 } 243 { 244 "File":"alloc/logs/redis.stdout.0", 245 "FileEvent": "file deleted" 246 } 247 ``` 248 249 </dd> 250 251 252 <dt>Field Reference</dt> 253 <dd> 254 The return value is a stream of frames. These frames contain the following 255 fields: 256 257 <ul> 258 <li> 259 <span class="param">Data</span> 260 A base64 encoding of the bytes being streamed. 261 </li> 262 <li> 263 <span class="param">FileEvent</span> 264 An event that could cause a change in the streams position. The possible 265 values are "file deleted" and "file truncated". 266 </li> 267 <li> 268 <span class="param">Offset</span> 269 Offset is the offset into the stream. 270 </li> 271 <li> 272 <span class="param">File</span> 273 The name of the file being streamed. 274 </li> 275 </ul> 276 </dd> 277 </dl> 278 279 <dl> 280 <dt>Description</dt> 281 <dd> 282 List files in an allocation directory. 283 </dd> 284 285 <dt>Method</dt> 286 <dd>GET</dd> 287 288 <dt>URL</dt> 289 <dd>`/v1/client/fs/ls/<Allocation-ID>`</dd> 290 291 <dt>Parameters</dt> 292 <dd> 293 <ul> 294 <li> 295 <span class="param">path</span> 296 <span class="param-flags">required</span> 297 The path relative to the root of the allocation directory. It 298 defaults to `/`, the root of the allocation directory. 299 </li> 300 </ul> 301 </dd> 302 303 <dt>Returns</dt> 304 <dd> 305 306 ```javascript 307 [ 308 { 309 "Name": "alloc", 310 "IsDir": true, 311 "Size": 4096, 312 "FileMode": "drwxrwxr-x", 313 "ModTime": "2016-03-15T15:40:00.414236712-07:00" 314 }, 315 { 316 "Name": "redis", 317 "IsDir": true, 318 "Size": 4096, 319 "FileMode": "drwxrwxr-x", 320 "ModTime": "2016-03-15T15:40:56.810238153-07:00" 321 } 322 ] 323 ``` 324 325 </dd> 326 </dl> 327 328 <dl> 329 <dt>Description</dt> 330 <dd> 331 Stat a file in an allocation directory. 332 </dd> 333 334 <dt>Method</dt> 335 <dd>GET</dd> 336 337 <dt>URL</dt> 338 <dd>`/v1/client/fs/stat/<Allocation-ID>`</dd> 339 340 <dt>Parameters</dt> 341 <dd> 342 <ul> 343 <li> 344 <span class="param">path</span> 345 <span class="param-flags">required</span> 346 The path of the file relative to the root of the allocation directory. 347 </li> 348 </ul> 349 </dd> 350 351 <dt>Returns</dt> 352 <dd> 353 354 ```javascript 355 { 356 "Name": "redis-syslog-collector.out", 357 "IsDir": false, 358 "Size": 96, 359 "FileMode": "-rw-rw-r--", 360 "ModTime": "2016-03-15T15:40:56.822238153-07:00" 361 } 362 ``` 363 364 </dd> 365 </dl>