github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/api-docs/evaluations.mdx (about) 1 --- 2 layout: api 3 page_title: Evaluations - HTTP API 4 description: The /evaluation are used to query for and interact with evaluations. 5 --- 6 7 # Evaluations HTTP API 8 9 The `/evaluation` endpoints are used to query for and interact with evaluations. 10 11 ## List Evaluations 12 13 This endpoint lists all evaluations. 14 15 | Method | Path | Produces | 16 | ------ | ----------------- | ------------------ | 17 | `GET` | `/v1/evaluations` | `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 evaluations 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 and is used before any `filter` expression is applied. 33 34 - `next_token` `(string: "")` - This endpoint supports paging. The 35 `next_token` parameter accepts a string which is the `ID` field of 36 the next expected evaluation. This value can be obtained from the 37 `X-Nomad-NextToken` header from the previous response. 38 39 - `per_page` `(int: 0)` - Specifies a maximum number of evaluations to 40 return for this request. If omitted, the response is not 41 paginated. The `ID` of the last evaluation in the response can be 42 used as the `last_token` of the next request to fetch additional 43 pages. 44 45 - `filter` `(string: "")` - Specifies the [expression](/api-docs#filtering) 46 used to filter the results. Consider using pagination or a query parameter to 47 reduce resource used to serve the request. 48 49 - `job` `(string: "")` - Filter the list of evaluations to a specific 50 job ID. 51 52 - `status` `(string: "")` - Filter the list of evaluations to a 53 specific evaluation status (one of `blocked`, `pending`, `complete`, 54 `failed`, or `canceled`). 55 56 - `namespace` `(string: "default")` - Specifies the target namespace. 57 Specifying `*` will return all evaluations across all authorized namespaces. 58 This parameter is used before any `filter` expression is applied. 59 60 - `reverse` `(bool: false)` - Specifies the list of returned evaluations should 61 be sorted in the reverse order. By default evaluations 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/evaluations 70 ``` 71 72 ```shell-session 73 $ curl \ 74 https://localhost:4646/v1/evaluations?prefix=25ba81 75 ``` 76 77 ### Sample Response 78 79 ```json 80 [ 81 { 82 "ID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577", 83 "Priority": 50, 84 "Type": "service", 85 "TriggeredBy": "job-register", 86 "JobID": "example", 87 "JobModifyIndex": 52, 88 "NodeID": "", 89 "NodeModifyIndex": 0, 90 "Status": "complete", 91 "StatusDescription": "", 92 "Wait": 0, 93 "NextEval": "", 94 "PreviousEval": "", 95 "BlockedEval": "", 96 "FailedTGAllocs": null, 97 "ClassEligibility": null, 98 "EscapedComputedClass": false, 99 "AnnotatePlan": false, 100 "SnapshotIndex": 53, 101 "QueuedAllocations": { 102 "cache": 0 103 }, 104 "CreateIndex": 53, 105 "ModifyIndex": 55 106 } 107 ] 108 ``` 109 110 ## Read Evaluation 111 112 This endpoint reads information about a specific evaluation by ID. 113 114 | Method | Path | Produces | 115 | ------ | ------------------------- | ------------------ | 116 | `GET` | `/v1/evaluation/:eval_id` | `application/json` | 117 118 The table below shows this endpoint's support for 119 [blocking queries](/api-docs#blocking-queries) and 120 [required ACLs](/api-docs#acls). 121 122 | Blocking Queries | ACL Required | 123 | ---------------- | -------------------- | 124 | `YES` | `namespace:read-job` | 125 126 ### Parameters 127 128 - `:eval_id` `(string: <required>)`- Specifies the UUID of the evaluation. This 129 must be the full UUID, not the short 8-character one. This is specified as 130 part of the path. 131 132 - `related` `(bool: false)` - Specifies if related evaluations should be 133 returned. Related evaluations are the ones that can be reached by following 134 the trail of IDs for `NextEval`, `PreviousEval`, and `BlockedEval`. This is 135 specified as a query parameter. 136 137 ### Sample Request 138 139 ```shell-session 140 $ curl \ 141 https://localhost:4646/v1/evaluation/2deb5f06-a100-f01a-3316-5e501a4965e7?related=true 142 ``` 143 144 ### Sample Response 145 146 ```json 147 { 148 "CreateIndex": 28, 149 "CreateTime": 1647394818583344000, 150 "FailedTGAllocs": { 151 "cache": { 152 "AllocationTime": 4111, 153 "ClassExhausted": null, 154 "ClassFiltered": null, 155 "CoalescedFailures": 0, 156 "ConstraintFiltered": null, 157 "DimensionExhausted": null, 158 "NodesAvailable": { 159 "dc1": 0 160 }, 161 "NodesEvaluated": 0, 162 "NodesExhausted": 0, 163 "NodesFiltered": 0, 164 "QuotaExhausted": null, 165 "ResourcesExhausted": null, 166 "ScoreMetaData": null, 167 "Scores": null 168 } 169 }, 170 "ID": "2deb5f06-a100-f01a-3316-5e501a4965e7", 171 "JobID": "example", 172 "ModifyIndex": 28, 173 "ModifyTime": 1647394818583344000, 174 "Namespace": "default", 175 "PreviousEval": "0f98f7ea-59ae-4d90-d9bd-b8ce80b9e100", 176 "Priority": 50, 177 "RelatedEvals": [ 178 { 179 "BlockedEval": "2deb5f06-a100-f01a-3316-5e501a4965e7", 180 "CreateIndex": 27, 181 "CreateTime": 1647394818582736000, 182 "DeploymentID": "79ae0a49-acf6-0fcf-183f-8646f3167b88", 183 "ID": "0f98f7ea-59ae-4d90-d9bd-b8ce80b9e100", 184 "JobID": "example", 185 "ModifyIndex": 30, 186 "ModifyTime": 1647394818583565000, 187 "Namespace": "default", 188 "NextEval": "", 189 "NodeID": "", 190 "PreviousEval": "", 191 "Priority": 50, 192 "Status": "complete", 193 "StatusDescription": "", 194 "TriggeredBy": "node-drain", 195 "Type": "service", 196 "WaitUntil": null 197 } 198 ], 199 "SnapshotIndex": 27, 200 "Status": "blocked", 201 "StatusDescription": "created to place remaining allocations", 202 "TriggeredBy": "queued-allocs", 203 "Type": "service" 204 } 205 ``` 206 207 ## Delete Evaluations 208 209 This endpoint deletes evaluations. In order to utilise this endpoint the 210 eval broker should be paused via the 211 [operator scheduler update configuration][update_scheduler_configuration] API 212 endpoint. 213 214 This API endpoint should be used cautiously and only in outage situations where 215 there is a large backlog of evaluations not being processed. During most normal 216 and outage scenarios, Nomad's reconciliation and state management will handle 217 evaluations as needed. 218 219 | Method | Path | Produces | 220 | --------- | ----------------- | ------------------ | 221 | `DELETE` | `/v1/evaluations` | `application/json` | 222 223 The table below shows this endpoint's support for 224 [blocking queries](/api-docs#blocking-queries) and 225 [required ACLs](/api-docs#acls). 226 227 | Blocking Queries | ACL Required | 228 | ---------------- | ------------ | 229 | `NO` | `management` | 230 231 ### Parameters 232 233 - `EvalIDs` `(array<string>: <required>)`- An array of evaluation UUIDs to 234 delete. This must be a full length UUID and not a prefix. 235 236 ### Sample Payload 237 238 ```javascript 239 { 240 "EvalIDs": [ 241 "167ec27d-2e36-979a-280a-a6b920d382db", 242 "6c193955-ac66-42e2-f4c7-f1fc707f1f5e" 243 ] 244 } 245 ``` 246 247 ### Sample Request 248 249 ```shell-session 250 $ curl \ 251 --request DELETE \ 252 --data @payload.json \ 253 https://localhost:4646/v1/evaluations 254 ``` 255 256 ## List Allocations for Evaluation 257 258 This endpoint lists the allocations created or modified for the given 259 evaluation. 260 261 | Method | Path | Produces | 262 | ------ | ------------------------------------- | ------------------ | 263 | `GET` | `/v1/evaluation/:eval_id/allocations` | `application/json` | 264 265 The table below shows this endpoint's support for 266 [blocking queries](/api-docs#blocking-queries) and 267 [required ACLs](/api-docs#acls). 268 269 | Blocking Queries | ACL Required | 270 | ---------------- | -------------------- | 271 | `YES` | `namespace:read-job` | 272 273 ### Parameters 274 275 - `:eval_id` `(string: <required>)`- Specifies the UUID of the evaluation. This 276 must be the full UUID, not the short 8-character one. This is specified as 277 part of the path. 278 279 ### Sample Request 280 281 ```shell-session 282 $ curl \ 283 https://localhost:4646/v1/evaluation/5456bd7a-9fc0-c0dd-6131-cbee77f57577/allocations 284 ``` 285 286 ### Sample Response 287 288 ```json 289 [ 290 { 291 "ID": "a8198d79-cfdb-6593-a999-1e9adabcba2e", 292 "EvalID": "5456bd7a-9fc0-c0dd-6131-cbee77f57577", 293 "Name": "example.cache[0]", 294 "NodeID": "fb2170a8-257d-3c64-b14d-bc06cc94e34c", 295 "JobID": "example", 296 "TaskGroup": "cache", 297 "DesiredStatus": "run", 298 "DesiredDescription": "", 299 "ClientStatus": "running", 300 "ClientDescription": "", 301 "TaskStates": { 302 "redis": { 303 "State": "running", 304 "Failed": false, 305 "Events": [ 306 { 307 "Type": "Received", 308 "Time": 1495747371795703800, 309 "FailsTask": false, 310 "RestartReason": "", 311 "SetupError": "", 312 "DriverError": "", 313 "ExitCode": 0, 314 "Signal": 0, 315 "Message": "", 316 "KillTimeout": 0, 317 "KillError": "", 318 "KillReason": "", 319 "StartDelay": 0, 320 "DownloadError": "", 321 "ValidationError": "", 322 "DiskLimit": 0, 323 "FailedSibling": "", 324 "VaultError": "", 325 "TaskSignalReason": "", 326 "TaskSignal": "", 327 "DriverMessage": "" 328 }, 329 { 330 "Type": "Driver", 331 "Time": 1495747371798867200, 332 "FailsTask": false, 333 "RestartReason": "", 334 "SetupError": "", 335 "DriverError": "", 336 "ExitCode": 0, 337 "Signal": 0, 338 "Message": "", 339 "KillTimeout": 0, 340 "KillError": "", 341 "KillReason": "", 342 "StartDelay": 0, 343 "DownloadError": "", 344 "ValidationError": "", 345 "DiskLimit": 0, 346 "FailedSibling": "", 347 "VaultError": "", 348 "TaskSignalReason": "", 349 "TaskSignal": "", 350 "DriverMessage": "Downloading image redis:7" 351 }, 352 { 353 "Type": "Started", 354 "Time": 1495747379525667800, 355 "FailsTask": false, 356 "RestartReason": "", 357 "SetupError": "", 358 "DriverError": "", 359 "ExitCode": 0, 360 "Signal": 0, 361 "Message": "", 362 "KillTimeout": 0, 363 "KillError": "", 364 "KillReason": "", 365 "StartDelay": 0, 366 "DownloadError": "", 367 "ValidationError": "", 368 "DiskLimit": 0, 369 "FailedSibling": "", 370 "VaultError": "", 371 "TaskSignalReason": "", 372 "TaskSignal": "", 373 "DriverMessage": "" 374 } 375 ] 376 } 377 }, 378 "CreateIndex": 54, 379 "ModifyIndex": 57, 380 "CreateTime": 1495747371794276400 381 } 382 ] 383 ``` 384 385 ## Count Evaluations 386 387 This endpoint counts evaluations. Note that Nomad's state store architecture 388 makes calculating this count unexpectedly expensive (similar in cost to the List 389 API), and this API was designed for use during recovery operations with the 390 `nomad eval delete` command. It is not recommended to use this API for 391 monitoring. The `nomad.nomad.broker.*` metrics are better for that use 392 case. See the [metrics reference][] for details. 393 394 395 | Method | Path | Produces | 396 |--------|-------------------------|--------------------| 397 | `GET` | `/v1/evaluations/count` | `application/json` | 398 399 The table below shows this endpoint's support for 400 [blocking queries](/api-docs#blocking-queries) and 401 [required ACLs](/api-docs#acls). 402 403 | Blocking Queries | ACL Required | 404 | ---------------- | -------------------- | 405 | `YES` | `namespace:read-job` | 406 407 ### Parameters 408 409 - `prefix` `(string: "")`- Specifies a string to filter evaluations based on an 410 ID prefix. Because the value is decoded to bytes, the prefix must have an even 411 number of hexadecimal characters (0-9a-f). This is specified as a query string 412 parameter and is used before any `filter` expression is applied. 413 414 - `filter` `(string: "")` - Specifies the [expression](/api-docs#filtering) used 415 to filter the results. 416 417 - `namespace` `(string: "default")` - Specifies the target namespace. 418 Specifying `*` will return all evaluations across all authorized namespaces. 419 This parameter is used before any `filter` expression is applied. 420 421 ### Sample Request 422 423 ```shell-session 424 $ curl \ 425 https://localhost:4646/v1/evaluations/count 426 ``` 427 428 ```shell-session 429 $ curl \ 430 https://localhost:4646/v1/evaluations/count?prefix=25ba81 431 ``` 432 433 ### Sample Response 434 435 ```json 436 { 437 "Count": 36 438 "Index": 133, 439 "KnownLeader": true, 440 "LastContact": 0, 441 "NextToken": "" 442 } 443 ``` 444 445 [update_scheduler_configuration]: /api-docs/operator/scheduler#update-scheduler-configuration 446 [metrics reference]: /docs/operations/metrics-reference