github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/api-docs/allocations.mdx (about)

     1  ---
     2  layout: api
     3  page_title: Allocations - HTTP API
     4  description: The /allocation endpoints are used to query for and interact with allocations.
     5  ---
     6  
     7  # Allocations HTTP API
     8  
     9  The `/allocation` endpoints are used to query for and interact with allocations.
    10  
    11  ## List Allocations
    12  
    13  This endpoint lists all allocations.
    14  
    15  | Method | Path              | Produces           |
    16  | ------ | ----------------- | ------------------ |
    17  | `GET`  | `/v1/allocations` | `application/json` |
    18  
    19  The table below shows this endpoint's support for
    20  [blocking queries](/api-docs#blocking-queries) and
    21  [required ACLs](/api-docs#acls).
    22  
    23  | Blocking Queries | ACL Required         |
    24  | ---------------- | -------------------- |
    25  | `YES`            | `namespace:read-job` |
    26  
    27  ### Parameters
    28  
    29  - `prefix` `(string: "")`- Specifies a string to filter allocations based on an
    30    ID prefix. Because the value is decoded to bytes, the prefix must have an
    31    even number of hexadecimal characters (0-9a-f). This is specified as a query
    32    string parameter.
    33  
    34  - `next_token` `(string: "")` - This endpoint supports paging. The `next_token`
    35    parameter accepts a string which identifies the next expected allocation.
    36    This value can be obtained from the `X-Nomad-NextToken` header from the
    37    previous response.
    38  
    39  - `per_page` `(int: 0)` - Specifies a maximum number of allocations to return
    40    for this request. If omitted, the response is not paginated. The value of the
    41    `X-Nomad-NextToken` header of the last response can be used as the
    42    `next_token` of the next request to fetch additional pages.
    43  
    44  - `filter` `(string: "")` - Specifies the [expression](/api-docs#filtering)
    45    used to filter the results. Consider using pagination or a query parameter to
    46    reduce resource used to serve the request.
    47  
    48  - `namespace` `(string: "default")` - Specifies the namespace to search. Specifying
    49    `*` would return all allocations across all the authorized namespaces.
    50  
    51  - `resources` `(bool: false)` - Specifies whether or not to include the
    52    `AllocatedResources` field in the response.
    53  
    54  - `task_states` `(bool: true)` - Specifies whether or not to include the
    55    `TaskStates` field in the response. TaskStates are included by default but
    56    can represent a large percentage of the overall response size. Clusters with
    57    a large number of allocations may set `task_states=false` to significantly
    58    reduce the size of the response.
    59  
    60  - `reverse` `(bool: false)` - Specifies the list of returned allocations should
    61    be sorted in the reverse order. By default allocations are returned sorted in
    62    chronological order (older evaluations first), or in lexicographical order by
    63    their ID if the `prefix` query parameter is used.
    64  
    65  ### Sample Request
    66  
    67  ```shell-session
    68  $ curl \
    69      https://localhost:4646/v1/allocations
    70  ```
    71  
    72  ```shell-session
    73  $ curl \
    74      https://localhost:4646/v1/allocations?prefix=a8198d79
    75  ```
    76  
    77  ```shell-session
    78  $ curl \
    79      https://localhost:4646/v1/allocations?namespace=*&prefix=a8198d79
    80  ```
    81  
    82  ### Sample Response
    83  
    84  ```json
    85  [
    86    {
    87      "ClientDescription": "Tasks are running",
    88      "ClientStatus": "running",
    89      "CreateIndex": 10,
    90      "CreateTime": 1636017249798459000,
    91      "DeploymentStatus": {
    92        "Canary": false,
    93        "Healthy": true,
    94        "ModifyIndex": 15,
    95        "Timestamp": "2021-11-04T10:14:22.054814+01:00"
    96      },
    97      "DesiredDescription": "",
    98      "DesiredStatus": "run",
    99      "DesiredTransition": {
   100        "ForceReschedule": null,
   101        "Migrate": null,
   102        "Reschedule": null
   103      },
   104      "EvalID": "cb20d15d-861f-8d8d-8253-e93932beea2e",
   105      "FollowupEvalID": "",
   106      "ID": "5457f16d-0f87-8e6b-5e91-0c7da3a41eb7",
   107      "JobID": "example",
   108      "JobType": "service",
   109      "JobVersion": 0,
   110      "ModifyIndex": 15,
   111      "ModifyTime": 1636017262190928000,
   112      "Name": "example.cache[0]",
   113      "Namespace": "default",
   114      "NodeID": "f476d2b4-02dc-c216-d031-273396727347",
   115      "NodeName": "linux",
   116      "PreemptedAllocations": null,
   117      "PreemptedByAllocation": "",
   118      "RescheduleTracker": null,
   119      "TaskGroup": "cache",
   120      "TaskStates": {
   121        "redis": {
   122          "Events": [
   123            {
   124              "Details": {},
   125              "DiskLimit": 0,
   126              "DisplayMessage": "Task received by client",
   127              "DownloadError": "",
   128              "DriverError": "",
   129              "DriverMessage": "",
   130              "ExitCode": 0,
   131              "FailedSibling": "",
   132              "FailsTask": false,
   133              "GenericSource": "",
   134              "KillError": "",
   135              "KillReason": "",
   136              "KillTimeout": 0,
   137              "Message": "",
   138              "RestartReason": "",
   139              "SetupError": "",
   140              "Signal": 0,
   141              "StartDelay": 0,
   142              "TaskSignal": "",
   143              "TaskSignalReason": "",
   144              "Time": 1636017249803624000,
   145              "Type": "Received",
   146              "ValidationError": "",
   147              "VaultError": ""
   148            },
   149            {
   150              "Details": {
   151                "message": "Building Task Directory"
   152              },
   153              "DiskLimit": 0,
   154              "DisplayMessage": "Building Task Directory",
   155              "DownloadError": "",
   156              "DriverError": "",
   157              "DriverMessage": "",
   158              "ExitCode": 0,
   159              "FailedSibling": "",
   160              "FailsTask": false,
   161              "GenericSource": "",
   162              "KillError": "",
   163              "KillReason": "",
   164              "KillTimeout": 0,
   165              "Message": "Building Task Directory",
   166              "RestartReason": "",
   167              "SetupError": "",
   168              "Signal": 0,
   169              "StartDelay": 0,
   170              "TaskSignal": "",
   171              "TaskSignalReason": "",
   172              "Time": 1636017249805254000,
   173              "Type": "Task Setup",
   174              "ValidationError": "",
   175              "VaultError": ""
   176            },
   177            {
   178              "Details": {},
   179              "DiskLimit": 0,
   180              "DisplayMessage": "Task started by client",
   181              "DownloadError": "",
   182              "DriverError": "",
   183              "DriverMessage": "",
   184              "ExitCode": 0,
   185              "FailedSibling": "",
   186              "FailsTask": false,
   187              "GenericSource": "",
   188              "KillError": "",
   189              "KillReason": "",
   190              "KillTimeout": 0,
   191              "Message": "",
   192              "RestartReason": "",
   193              "SetupError": "",
   194              "Signal": 0,
   195              "StartDelay": 0,
   196              "TaskSignal": "",
   197              "TaskSignalReason": "",
   198              "Time": 1636017252049956000,
   199              "Type": "Started",
   200              "ValidationError": "",
   201              "VaultError": ""
   202            }
   203          ],
   204          "Failed": false,
   205          "FinishedAt": null,
   206          "LastRestart": null,
   207          "Restarts": 0,
   208          "StartedAt": "2021-11-04T09:14:12.04996Z",
   209          "State": "running",
   210          "TaskHandle": null
   211        }
   212      }
   213    }
   214  ]
   215  ```
   216  
   217  ## Read Allocation
   218  
   219  This endpoint reads information about a specific allocation.
   220  
   221  | Method | Path                       | Produces           |
   222  | ------ | -------------------------- | ------------------ |
   223  | `GET`  | `/v1/allocation/:alloc_id` | `application/json` |
   224  
   225  The table below shows this endpoint's support for
   226  [blocking queries](/api-docs#blocking-queries) and
   227  [required ACLs](/api-docs#acls).
   228  
   229  | Blocking Queries | ACL Required         |
   230  | ---------------- | -------------------- |
   231  | `YES`            | `namespace:read-job` |
   232  
   233  ### Parameters
   234  
   235  - `:alloc_id` `(string: <required>)`- Specifies the UUID of the allocation. This
   236    must be the full UUID, not the short 8-character one. This is specified as
   237    part of the path.
   238  
   239  ### Sample Request
   240  
   241  ```shell-session
   242  $ curl \
   243      https://localhost:4646/v1/allocation/5456bd7a-9fc0-c0dd-6131-cbee77f57577
   244  ```
   245  
   246  ### Sample Response
   247  
   248  ```json
   249  {
   250    "ID": "a8198d79-cfdb-6593-a999-1e9adabcba2e",
   251    "EvalID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577",
   252    "Name": "example.cache[0]",
   253    "NodeID": "fb2170a8-257d-3c64-b14d-bc06cc94e34c",
   254    "PreviousAllocation": "516d2753-0513-cfc7-57ac-2d6fac18b9dc",
   255    "NextAllocation": "cd13d9b9-4f97-7184-c88b-7b451981616b",
   256    "RescheduleTracker": {
   257      "Events": [
   258        {
   259          "PrevAllocID": "516d2753-0513-cfc7-57ac-2d6fac18b9dc",
   260          "PrevNodeID": "9230cd3b-3bda-9a3f-82f9-b2ea8dedb20e",
   261          "RescheduleTime": 1517434161192946200,
   262          "Delay": "5000000000"
   263        }
   264      ]
   265    },
   266    "JobID": "example",
   267    "Job": {
   268      "Region": "global",
   269      "ID": "example",
   270      "ParentID": "",
   271      "Name": "example",
   272      "Type": "service",
   273      "Priority": 50,
   274      "AllAtOnce": false,
   275      "Datacenters": ["dc1"],
   276      "Constraints": null,
   277      "Affinities": null,
   278      "TaskGroups": [
   279        {
   280          "Name": "cache",
   281          "Count": 1,
   282          "Constraints": null,
   283          "Affinities": null,
   284          "RestartPolicy": {
   285            "Attempts": 10,
   286            "Interval": 300000000000,
   287            "Delay": 25000000000,
   288            "Mode": "delay"
   289          },
   290          "Spreads": null,
   291          "Tasks": [
   292            {
   293              "Name": "redis",
   294              "Driver": "docker",
   295              "User": "",
   296              "Config": {
   297                "port_map": [
   298                  {
   299                    "db": 6379
   300                  }
   301                ],
   302                "image": "redis:7"
   303              },
   304              "Env": null,
   305              "Services": [
   306                {
   307                  "Name": "redis-cache",
   308                  "PortLabel": "db",
   309                  "Tags": ["global", "cache"],
   310                  "Checks": [
   311                    {
   312                      "Name": "alive",
   313                      "Type": "tcp",
   314                      "Command": "",
   315                      "Args": null,
   316                      "Path": "",
   317                      "Protocol": "",
   318                      "PortLabel": "",
   319                      "Interval": 10000000000,
   320                      "Timeout": 2000000000,
   321                      "InitialStatus": ""
   322                    }
   323                  ]
   324                }
   325              ],
   326              "Vault": null,
   327              "Templates": null,
   328              "Constraints": null,
   329              "Affinities": null,
   330              "Resources": {
   331                "CPU": 500,
   332                "MemoryMB": 10,
   333                "DiskMB": 0,
   334                "Networks": [
   335                  {
   336                    "Device": "",
   337                    "CIDR": "",
   338                    "IP": "",
   339                    "MBits": 10,
   340                    "ReservedPorts": null,
   341                    "DynamicPorts": [
   342                      {
   343                        "Label": "db",
   344                        "Value": 0
   345                      }
   346                    ]
   347                  }
   348                ]
   349              },
   350              "Spreads": null,
   351              "DispatchPayload": null,
   352              "Meta": null,
   353              "KillTimeout": 5000000000,
   354              "LogConfig": {
   355                "MaxFiles": 10,
   356                "MaxFileSizeMB": 10
   357              },
   358              "Artifacts": null,
   359              "Leader": false
   360            }
   361          ],
   362          "EphemeralDisk": {
   363            "Sticky": false,
   364            "SizeMB": 300,
   365            "Migrate": false
   366          },
   367          "Meta": null
   368        }
   369      ],
   370      "Update": {
   371        "Stagger": 10000000000,
   372        "MaxParallel": 0
   373      },
   374      "Periodic": null,
   375      "ParameterizedJob": null,
   376      "Payload": null,
   377      "Spreads": null,
   378      "Meta": null,
   379      "VaultToken": "",
   380      "Status": "pending",
   381      "StatusDescription": "",
   382      "CreateIndex": 52,
   383      "ModifyIndex": 52,
   384      "JobModifyIndex": 52
   385    },
   386    "TaskGroup": "cache",
   387    "Resources": {
   388      "CPU": 500,
   389      "MemoryMB": 10,
   390      "DiskMB": 300,
   391      "Networks": [
   392        {
   393          "Device": "lo0",
   394          "CIDR": "",
   395          "IP": "127.0.0.1",
   396          "MBits": 10,
   397          "ReservedPorts": null,
   398          "DynamicPorts": [
   399            {
   400              "Label": "db",
   401              "Value": 23116
   402            }
   403          ]
   404        }
   405      ]
   406    },
   407    "SharedResources": {
   408      "CPU": 0,
   409      "MemoryMB": 0,
   410      "DiskMB": 300,
   411      "Networks": null
   412    },
   413    "TaskResources": {
   414      "redis": {
   415        "CPU": 500,
   416        "MemoryMB": 10,
   417        "DiskMB": 0,
   418        "Networks": [
   419          {
   420            "Device": "lo0",
   421            "CIDR": "",
   422            "IP": "127.0.0.1",
   423            "MBits": 10,
   424            "ReservedPorts": null,
   425            "DynamicPorts": [
   426              {
   427                "Label": "db",
   428                "Value": 23116
   429              }
   430            ]
   431          }
   432        ]
   433      }
   434    },
   435    "Metrics": {
   436      "NodesEvaluated": 1,
   437      "NodesFiltered": 0,
   438      "NodesAvailable": {
   439        "dc1": 1
   440      },
   441      "ClassFiltered": null,
   442      "ConstraintFiltered": null,
   443      "NodesExhausted": 0,
   444      "ClassExhausted": null,
   445      "DimensionExhausted": null,
   446      "Scores": {
   447        "fb2170a8-257d-3c64-b14d-bc06cc94e34c.binpack": 0.6205732522109244
   448      },
   449      "AllocationTime": 31729,
   450      "CoalescedFailures": 0
   451    },
   452    "DesiredStatus": "run",
   453    "DesiredDescription": "",
   454    "ClientStatus": "running",
   455    "ClientDescription": "",
   456    "TaskStates": {
   457      "redis": {
   458        "State": "running",
   459        "Failed": false,
   460        "FinishedAt": "0001-01-01T00:00:00Z",
   461        "LastRestart": "0001-01-01T00:00:00Z",
   462        "Restarts": 0,
   463        "StartedAt": "2017-07-25T23:36:26.106431265Z",
   464        "Events": [
   465          {
   466            "Type": "Received",
   467            "Time": 1495747371795703800,
   468            "FailsTask": false,
   469            "RestartReason": "",
   470            "SetupError": "",
   471            "DriverError": "",
   472            "ExitCode": 0,
   473            "Signal": 0,
   474            "Message": "",
   475            "KillTimeout": 0,
   476            "KillError": "",
   477            "KillReason": "",
   478            "StartDelay": 0,
   479            "DownloadError": "",
   480            "ValidationError": "",
   481            "DiskLimit": 0,
   482            "FailedSibling": "",
   483            "VaultError": "",
   484            "TaskSignalReason": "",
   485            "TaskSignal": "",
   486            "DriverMessage": ""
   487          },
   488          {
   489            "Type": "Driver",
   490            "Time": 1495747371798867200,
   491            "FailsTask": false,
   492            "RestartReason": "",
   493            "SetupError": "",
   494            "DriverError": "",
   495            "ExitCode": 0,
   496            "Signal": 0,
   497            "Message": "",
   498            "KillTimeout": 0,
   499            "KillError": "",
   500            "KillReason": "",
   501            "StartDelay": 0,
   502            "DownloadError": "",
   503            "ValidationError": "",
   504            "DiskLimit": 0,
   505            "FailedSibling": "",
   506            "VaultError": "",
   507            "TaskSignalReason": "",
   508            "TaskSignal": "",
   509            "DriverMessage": "Downloading image redis:7"
   510          },
   511          {
   512            "Type": "Started",
   513            "Time": 1495747379525667800,
   514            "FailsTask": false,
   515            "RestartReason": "",
   516            "SetupError": "",
   517            "DriverError": "",
   518            "ExitCode": 0,
   519            "Signal": 0,
   520            "Message": "",
   521            "KillTimeout": 0,
   522            "KillError": "",
   523            "KillReason": "",
   524            "StartDelay": 0,
   525            "DownloadError": "",
   526            "ValidationError": "",
   527            "DiskLimit": 0,
   528            "FailedSibling": "",
   529            "VaultError": "",
   530            "TaskSignalReason": "",
   531            "TaskSignal": "",
   532            "DriverMessage": ""
   533          }
   534        ]
   535      }
   536    },
   537    "PreviousAllocation": "",
   538    "CreateIndex": 54,
   539    "ModifyIndex": 57,
   540    "AllocModifyIndex": 54,
   541    "CreateTime": 1495747371794276400,
   542    "ModifyTime": 1495747371794276400
   543  }
   544  ```
   545  
   546  #### Field Reference
   547  
   548  - `Job` - A copy of the job at the time that the allocation is created or
   549    updated. This is primarily intended for use by the Nomad client when running
   550    the allocation, and it may include stale information on some job fields.
   551    Up-to-date information about the job status is available from the
   552    [jobs API](/api-docs/jobs); take care to fetch the version of the job
   553    associated with this allocation.
   554  
   555  - `TaskStates` - A map of tasks to their current state and the latest events
   556    that have effected the state. `TaskState` objects contain the following
   557    fields:
   558  
   559    - `State`: The task's current state. It can have one of the following
   560      values:
   561  
   562      - `TaskStatePending` - The task is waiting to be run, either for the first
   563        time or due to a restart.
   564  
   565      - `TaskStateRunning` - The task is currently running.
   566  
   567      - `TaskStateDead` - The task is dead and will not run again.
   568  
   569    - `StartedAt`: The time the task was last started at. Can be updated through
   570      restarts.
   571  
   572    - `FinishedAt`: The time the task was finished at.
   573  
   574    - `LastRestart`: The last time the task was restarted.
   575  
   576    - `Restarts`: The number of times the task has restarted.
   577  
   578    - `Events` - An event contains metadata about the event. The latest 10 events
   579      are stored per task. Each event is timestamped (Unix nanoseconds) and has one
   580      of the following types:
   581  
   582      - `Setup Failure` - The task could not be started because there was a
   583        failure setting up the task prior to it running.
   584  
   585      - `Driver Failure` - The task could not be started due to a failure in the
   586        driver.
   587  
   588      - `Started` - The task was started; either for the first time or due to a
   589        restart.
   590  
   591      - `Terminated` - The task was started and exited.
   592  
   593      - `Killing` - The task has been sent the kill signal.
   594  
   595      - `Killed` - The task was killed by a user.
   596  
   597      - `Received` - The task has been pulled by the client at the given timestamp.
   598  
   599      - `Failed Validation` - The task was invalid and as such it didn't run.
   600  
   601      - `Restarting` - The task terminated and is being restarted.
   602  
   603      - `Not Restarting` - the task has failed and is not being restarted because
   604        it has exceeded its restart policy.
   605  
   606      - `Downloading Artifacts` - The task is downloading the artifact(s)
   607      - specified in the task.
   608  
   609      - `Failed Artifact Download` - Artifact(s) specified in the task failed to
   610        download.
   611  
   612      - `Restart Signaled` - The task was signaled to be restarted.
   613  
   614      - `Signaling` - The task was is being sent a signal.
   615  
   616      - `Sibling Task Failed` - A task in the same task group failed.
   617  
   618      - `Leader Task Dead` - The group's leader task is dead.
   619  
   620      - `Driver` - A message from the driver.
   621  
   622      - `Task Setup` - Task setup messages.
   623  
   624      - `Building Task Directory` - Task is building its file system.
   625  
   626      Depending on the type the event will have applicable annotations.
   627  
   628  ## Stop Allocation
   629  
   630  This endpoint stops and reschedules a specific allocation.
   631  
   632  | Method         | Path                            | Produces           |
   633  | -------------- | ------------------------------- | ------------------ |
   634  | `POST` / `PUT` | `/v1/allocation/:alloc_id/stop` | `application/json` |
   635  
   636  The table below shows this endpoint's support for
   637  [blocking queries](/api-docs#blocking-queries) and
   638  [required ACLs](/api-docs#acls).
   639  
   640  | Blocking Queries | ACL Required                |
   641  | ---------------- | --------------------------- |
   642  | `NO`             | `namespace:alloc-lifecycle` |
   643  
   644  ### Parameters
   645  
   646  - `:alloc_id` `(string: <required>)`- Specifies the UUID of the allocation. This
   647    must be the full UUID, not the short 8-character one. This is specified as
   648    part of the path.
   649  
   650  ### Sample Request
   651  
   652  ```shell-session
   653  $ curl -X POST \
   654      https://localhost:4646/v1/allocation/5456bd7a-9fc0-c0dd-6131-cbee77f57577/stop
   655  ```
   656  
   657  ### Sample Response
   658  
   659  ```json
   660  {
   661    "EvalID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577",
   662    "Index": 54
   663  }
   664  ```
   665  
   666  ## Signal Allocation
   667  
   668  This endpoint sends a signal to an allocation or task.
   669  
   670  | Method         | Path                                     | Produces           |
   671  | -------------- | ---------------------------------------- | ------------------ |
   672  | `POST` / `PUT` | `/v1/client/allocation/:alloc_id/signal` | `application/json` |
   673  
   674  The table below shows this endpoint's support for
   675  [blocking queries](/api-docs#blocking-queries) and
   676  [required ACLs](/api-docs#acls).
   677  
   678  | Blocking Queries | ACL Required                |
   679  | ---------------- | --------------------------- |
   680  | `NO`             | `namespace:alloc-lifecycle` |
   681  
   682  ### Parameters
   683  
   684  - `:alloc_id` `(string: <required>)`- Specifies the UUID of the allocation. This
   685    must be the full UUID, not the short 8-character one. This is specified as
   686    part of the path.
   687  
   688  ### Sample Payload
   689  
   690  ```json
   691  {
   692    "Signal": "SIGUSR1",
   693    "Task": "FOO"
   694  }
   695  ```
   696  
   697  If `Task` is omitted, the signal will be sent to all tasks in the allocation.
   698  
   699  ### Sample Request
   700  
   701  ```shell-session
   702  $ curl -X POST -d '{"Signal": "SIGUSR1" }' \
   703      https://localhost:4646/v1/client/allocation/5456bd7a-9fc0-c0dd-6131-cbee77f57577/signal
   704  ```
   705  
   706  ### Sample Response
   707  
   708  ```json
   709  {}
   710  ```
   711  
   712  ## Restart Allocation
   713  
   714  This endpoint restarts an allocation or task in-place.
   715  
   716  | Method         | Path                                      | Produces           |
   717  | -------------- | ----------------------------------------- | ------------------ |
   718  | `POST` / `PUT` | `/v1/client/allocation/:alloc_id/restart` | `application/json` |
   719  
   720  The table below shows this endpoint's support for
   721  [blocking queries](/api-docs#blocking-queries) and
   722  [required ACLs](/api-docs#acls).
   723  
   724  | Blocking Queries | ACL Required                |
   725  | ---------------- | --------------------------- |
   726  | `NO`             | `namespace:alloc-lifecycle` |
   727  
   728  ### Parameters
   729  
   730  - `:alloc_id` `(string: <required>)`- Specifies the UUID of the allocation. This
   731    must be the full UUID, not the short 8-character one. This is specified as
   732    part of the path.
   733  
   734  - `TaskName` `(string: "")` - Specifies the individual task to restart. Cannot
   735    be used with `AllTasks` set to `true`.
   736  
   737  - `AllTasks` `(bool: false)` -  If set to `true` all tasks in the allocation
   738    will be restarted, even the ones that already ran. Cannot be set to `true` if
   739    `TaskName` is defined.
   740  
   741  ### Sample Payload
   742  
   743  ```json
   744  {
   745    "TaskName": "FOO"
   746  }
   747  ```
   748  
   749  ### Sample Request
   750  
   751  ```shell-session
   752  $ curl -X POST -d '{"TaskName": "redis" }' \
   753      https://localhost:4646/v1/client/allocation/5456bd7a-9fc0-c0dd-6131-cbee77f57577/restart
   754  ```
   755  
   756  ### Sample Response
   757  
   758  ```json
   759  {}
   760  ```
   761  
   762  ## Exec Allocation
   763  
   764  This endpoint executes a command inside the isolation container where an allocation is running.
   765  It opens a WebSocket to transmit input to and output from the command.
   766  
   767  | Method      | Path                                   | Produces               |
   768  | ----------- | -------------------------------------- | ---------------------- |
   769  | `WebSocket` | `/v1/client/allocation/:alloc_id/exec` | WebSocket JSON streams |
   770  
   771  The table below shows this endpoint's support for
   772  [blocking queries](/api-docs#blocking-queries) and
   773  [required ACLs](/api-docs#acls).
   774  
   775  | Blocking Queries | ACL Required                                                                                 |
   776  | ---------------- | -------------------------------------------------------------------------------------------- |
   777  | `NO`             | `namespace:alloc-exec` (and `namespace:alloc-node-exec` if target task uses raw_exec driver) |
   778  
   779  ### Parameters
   780  
   781  - `:alloc_id` `(string: <required>)`- Specifies the UUID of the allocation. This
   782    must be the full UUID, not the short 8-character one. This is specified as
   783    part of the path.
   784  - `command` `(string: <required>)` - Specifies the command to be executed. This
   785    must be a JSON-encoded array of the command to be executed, e.g. `["echo", "hi"]`
   786    or `["/bin/bash"]`. This is specified as a query parameter.
   787  - `task` `(string: <required>)` - Specifies the task name, as a query parameter.
   788  - `tty` `(bool: false)` - Specifies whether a TTY is allocated for this task, as
   789    a query parameter.
   790  - `ws_handshake` `(bool: false)` - Specifies whether to expect the authentication
   791    token in the first frame, as a query parameter.
   792  
   793  ### Request Frames
   794  
   795  Request frames represent the `stdin` stream from the command as well as TTY resize events.
   796  When `?ws_handshake=true`, the first request frame must contain the authentication token.
   797  
   798  The following are valid formats:
   799  
   800  ```
   801  # sending authentication token
   802  {"version":1,"auth_token":"fc3c1968-8d31-5c50-9617-3db2e19ef32e"}
   803  
   804  # sending stdin data
   805  {"stdin": {"data": "...base64 encoded string of bytes ..."}}
   806  
   807  # indicating stdin is closed
   808  {"stdin": {"close": true}}
   809  
   810  # indicating that TTY was resized
   811  {"tty_size": {"height": <characters>, "width": <characters>}}
   812  
   813  # basic application-level heartbeat
   814  {}
   815  ```
   816  
   817  ### Response Frames
   818  
   819  Response frames represent `stdout` and `stderr` output from the command as well as exit codes:
   820  
   821  ```
   822  # transferring stdout data
   823  {"stdout": {"data": "...base64 encoded string of bytes ..."}}
   824  
   825  # signaling that host closed stdout
   826  {"stdout": {"close": true}}
   827  
   828  # transferring stderr data
   829  {"stderr": {"data": "...base64 encoded string of bytes ..."}}
   830  
   831  # signaling that host closed stderr
   832  {"stderr": {"close": true}}
   833  
   834  # signaling process exited
   835  {"exited": true, "result": {"exit_code": <exit_code_int>}}
   836  
   837  # basic application-level heartbeat
   838  {}
   839  ```
   840  
   841  ### Sample Request and Response
   842  
   843  Request and response frames encompass the full range of terminal emulator inputs and outputs, including the control characters necessary to render interactive applications. The example response includes instances of the ANSI “control sequence introducer” (CSI), which is ASCII code 27 followed by `[`.
   844  
   845  ```
   846  # \x12: form feed, to clear terminal
   847  {"stdin":{"data":"DA=="}}
   848  
   849  # "\x1b[H\x1b[2J$ ":
   850  # CSI-H (move cursor to top left corner), CSI-2J (clear entire screen), print "$ "
   851  {"stdout":{"data":"G1tIG1sySiQg"}}
   852  ```
   853  
   854  ## Allocation Services
   855  
   856  The endpoint is used to read all services registered within Nomad belonging to the passed
   857  allocation ID.
   858  
   859  | Method | Path                             | Produces           |
   860  | ------ | -------------------------------- | ------------------ |
   861  | `GET`  | `/allocation/:alloc_id/services` | `application/json` |
   862  
   863  The table below shows this endpoint's support for
   864  [blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
   865  [required ACLs](/api-docs#acls).
   866  
   867  | Blocking Queries | Consistency Modes | ACL Required         |
   868  | ---------------- | ----------------- | -------------------- |
   869  | `YES`            | `all`             | `namespace:read-job` |
   870  
   871  ### Parameters
   872  
   873  - `:alloc_id` `(string: <required>)` - Specifies the service name. This is
   874  specified as part of the path.
   875  
   876  - `namespace` `(string: "default")` - Specifies the target namespace.
   877  
   878  ### Sample Request
   879  
   880  ```shell-session
   881  $ curl \
   882      https://localhost:4646/v1/allocation/177160af-26f6-619f-9c9f-5e46d1104395/services
   883  ```
   884  
   885  ### Sample Response
   886  
   887  ```json
   888  [
   889    {
   890      "Address": "127.0.0.1",
   891      "AllocID": "177160af-26f6-619f-9c9f-5e46d1104395",
   892      "CreateIndex": 14,
   893      "Datacenter": "dc1",
   894      "ID": "_nomad-task-177160af-26f6-619f-9c9f-5e46d1104395-redis-example-cache-redis-db",
   895      "JobID": "example",
   896      "ModifyIndex": 24,
   897      "Namespace": "default",
   898      "NodeID": "7406e90b-de16-d118-80fe-60d0f2730cb3",
   899      "Port": 29702,
   900      "ServiceName": "example-cache-redis",
   901      "Tags": [
   902        "db",
   903        "cache"
   904      ]
   905    }
   906  ]
   907  ```