github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/api-docs/jobs.mdx (about) 1 --- 2 layout: api 3 page_title: Jobs - HTTP API 4 sidebar_title: Jobs 5 description: The /jobs endpoints are used to query for and interact with jobs. 6 --- 7 8 # Jobs HTTP API 9 10 The `/jobs` endpoints are used to query for and interact with jobs. 11 12 ## List Jobs 13 14 This endpoint lists all known jobs in the system registered with Nomad. 15 16 | Method | Path | Produces | 17 | ------ | ---------- | ------------------ | 18 | `GET` | `/v1/jobs` | `application/json` | 19 20 The table below shows this endpoint's support for 21 [blocking queries](/api-docs#blocking-queries) and 22 [required ACLs](/api-docs#acls). 23 24 | Blocking Queries | ACL Required | 25 | ---------------- | --------------------- | 26 | `YES` | `namespace:list-jobs` | 27 28 ### Parameters 29 30 - `prefix` `(string: "")` - Specifies a string to filter jobs on based on 31 an index prefix. This is specified as a query string parameter. 32 33 ### Sample Request 34 35 ```shell-sessioncurl \ 36 https://localhost:4646/v1/jobs 37 ``` 38 39 ```shell-sessioncurl \ 40 https://localhost:4646/v1/jobs?prefix=team 41 ``` 42 43 ### Sample Response 44 45 ```json 46 [ 47 { 48 "ID": "example", 49 "ParentID": "", 50 "Name": "example", 51 "Type": "service", 52 "Priority": 50, 53 "Status": "pending", 54 "StatusDescription": "", 55 "JobSummary": { 56 "JobID": "example", 57 "Summary": { 58 "cache": { 59 "Queued": 1, 60 "Complete": 1, 61 "Failed": 0, 62 "Running": 0, 63 "Starting": 0, 64 "Lost": 0 65 } 66 }, 67 "Children": { 68 "Pending": 0, 69 "Running": 0, 70 "Dead": 0 71 }, 72 "CreateIndex": 52, 73 "ModifyIndex": 96 74 }, 75 "CreateIndex": 52, 76 "ModifyIndex": 93, 77 "JobModifyIndex": 52 78 } 79 ] 80 ``` 81 82 ## Create Job 83 84 This endpoint creates (aka "registers") a new job in the system. 85 86 | Method | Path | Produces | 87 | ------ | ---------- | ------------------ | 88 | `POST` | `/v1/jobs` | `application/json` | 89 90 The table below shows this endpoint's support for 91 [blocking queries](/api-docs#blocking-queries) and 92 [required ACLs](/api-docs#acls). 93 94 | Blocking Queries | ACL Required | 95 | ---------------- | --------------------------------------------------------------------------------- | 96 | `NO` | `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 97 98 ### Parameters 99 100 - `Job` `(Job: <required>)` - Specifies the JSON definition of the job. 101 102 - `EnforceIndex` `(bool: false)` - If set, the job will only be registered if the 103 passed `JobModifyIndex` matches the current job's index. If the index is zero, 104 the register only occurs if the job is new. This paradigm allows check-and-set 105 style job updating. 106 107 - `JobModifyIndex` `(int: 0)` - Specifies the `JobModifyIndex` to enforce the 108 current job is at. 109 110 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 111 will be overridden. This allows a job to be registered when it would be denied 112 by policy. 113 114 ### Sample Payload 115 116 ```json 117 { 118 "Job": { 119 "ID": "example", 120 "Name": "example", 121 "Type": "service", 122 "Priority": 50, 123 "Datacenters": ["dc1"], 124 "TaskGroups": [ 125 { 126 "Name": "cache", 127 "Count": 1, 128 "Tasks": [ 129 { 130 "Name": "redis", 131 "Driver": "docker", 132 "User": "", 133 "Config": { 134 "image": "redis:3.2", 135 "port_map": [ 136 { 137 "db": 6379 138 } 139 ] 140 }, 141 "Services": [ 142 { 143 "Id": "", 144 "Name": "redis-cache", 145 "Tags": ["global", "cache"], 146 "Meta": { 147 "meta": "for my service" 148 }, 149 "PortLabel": "db", 150 "AddressMode": "", 151 "Checks": [ 152 { 153 "Id": "", 154 "Name": "alive", 155 "Type": "tcp", 156 "Command": "", 157 "Args": null, 158 "Path": "", 159 "Protocol": "", 160 "PortLabel": "", 161 "Interval": 10000000000, 162 "Timeout": 2000000000, 163 "InitialStatus": "", 164 "TLSSkipVerify": false 165 } 166 ] 167 } 168 ], 169 "Resources": { 170 "CPU": 500, 171 "MemoryMB": 256, 172 "Networks": [ 173 { 174 "Device": "", 175 "CIDR": "", 176 "IP": "", 177 "MBits": 10, 178 "DynamicPorts": [ 179 { 180 "Label": "db", 181 "Value": 0 182 } 183 ] 184 } 185 ] 186 }, 187 "Leader": false 188 } 189 ], 190 "RestartPolicy": { 191 "Interval": 300000000000, 192 "Attempts": 10, 193 "Delay": 25000000000, 194 "Mode": "delay" 195 }, 196 "ReschedulePolicy": { 197 "Attempts": 10, 198 "Delay": 30000000000, 199 "DelayFunction": "exponential", 200 "Interval": 36000000000000, 201 "MaxDelay": 3600000000000, 202 "Unlimited": false 203 }, 204 "EphemeralDisk": { 205 "SizeMB": 300 206 } 207 } 208 ], 209 "Update": { 210 "MaxParallel": 1, 211 "MinHealthyTime": 10000000000, 212 "HealthyDeadline": 180000000000, 213 "AutoRevert": false, 214 "Canary": 0 215 } 216 } 217 } 218 ``` 219 220 ### Sample Request 221 222 ```shell-sessioncurl \ 223 --request POST \ 224 --data @payload.json \ 225 https://localhost:4646/v1/jobs 226 ``` 227 228 ### Sample Response 229 230 ```json 231 { 232 "EvalID": "", 233 "EvalCreateIndex": 0, 234 "JobModifyIndex": 109, 235 "Warnings": "", 236 "Index": 0, 237 "LastContact": 0, 238 "KnownLeader": false 239 } 240 ``` 241 242 ## Parse Job 243 244 This endpoint will parse a HCL jobspec and produce the equivalent JSON encoded 245 job. 246 247 | Method | Path | Produces | 248 | ------ | ---------------- | ------------------ | 249 | `POST` | `/v1/jobs/parse` | `application/json` | 250 251 The table below shows this endpoint's support for 252 [blocking queries](/api-docs#blocking-queries) and 253 [required ACLs](/api-docs#acls). 254 255 | Blocking Queries | ACL Required | 256 | ---------------- | ------------ | 257 | `NO` | `none` | 258 259 ### Parameters 260 261 - `JobHCL` `(string: <required>)` - Specifies the HCL definition of the job 262 encoded in a JSON string. 263 - `Canonicalize` `(bool: false)` - Flag to enable setting any unset fields to 264 their default values. 265 266 ## Sample Payload 267 268 ```json 269 { 270 "JobHCL": "job \"example\" { type = \"service\" group \"cache\" {} }", 271 "Canonicalize": true 272 } 273 ``` 274 275 ### Sample Request 276 277 ```shell-sessioncurl \ 278 --request POST \ 279 --data @payload.json \ 280 https://localhost:4646/v1/jobs/parse 281 ``` 282 283 ### Sample Response 284 285 ```json 286 { 287 "AllAtOnce": false, 288 "Constraints": null, 289 "Affinities": null, 290 "CreateIndex": 0, 291 "Datacenters": null, 292 "ID": "my-job", 293 "JobModifyIndex": 0, 294 "Meta": null, 295 "Migrate": null, 296 "ModifyIndex": 0, 297 "Name": "my-job", 298 "Namespace": "default", 299 "ParameterizedJob": null, 300 "ParentID": "", 301 "Payload": null, 302 "Periodic": null, 303 "Priority": 50, 304 "Region": "global", 305 "Reschedule": null, 306 "Stable": false, 307 "Status": "", 308 "StatusDescription": "", 309 "Stop": false, 310 "SubmitTime": null, 311 "TaskGroups": null, 312 "Type": "service", 313 "Update": null, 314 "VaultToken": "", 315 "Version": 0 316 } 317 ``` 318 319 ## Read Job 320 321 This endpoint reads information about a single job for its specification and 322 status. 323 324 | Method | Path | Produces | 325 | ------ | ----------------- | ------------------ | 326 | `GET` | `/v1/job/:job_id` | `application/json` | 327 328 The table below shows this endpoint's support for 329 [blocking queries](/api-docs#blocking-queries) and 330 [required ACLs](/api-docs#acls). 331 332 | Blocking Queries | ACL Required | 333 | ---------------- | -------------------- | 334 | `YES` | `namespace:read-job` | 335 336 ### Parameters 337 338 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 339 the job file during submission). This is specified as part of the path. 340 341 ### Sample Request 342 343 ```shell-sessioncurl \ 344 https://localhost:4646/v1/job/my-job 345 ``` 346 347 ### Sample Response 348 349 ```json 350 { 351 "Region": "global", 352 "ID": "example", 353 "ParentID": "", 354 "Name": "example", 355 "Type": "batch", 356 "Priority": 50, 357 "AllAtOnce": false, 358 "Datacenters": ["dc1"], 359 "Constraints": [ 360 { 361 "LTarget": "${attr.kernel.name}", 362 "RTarget": "linux", 363 "Operand": "=" 364 } 365 ], 366 "TaskGroups": [ 367 { 368 "Name": "cache", 369 "Count": 1, 370 "Constraints": [ 371 { 372 "LTarget": "${attr.os.signals}", 373 "RTarget": "SIGUSR1", 374 "Operand": "set_contains" 375 } 376 ], 377 "Affinities": [ 378 { 379 "LTarget": "${meta.datacenter}", 380 "RTarget": "dc1", 381 "Operand": "=", 382 "Weight": 50 383 } 384 ], 385 "RestartPolicy": { 386 "Attempts": 10, 387 "Interval": 300000000000, 388 "Delay": 25000000000, 389 "Mode": "delay" 390 }, 391 "Tasks": [ 392 { 393 "Name": "redis", 394 "Driver": "docker", 395 "User": "foo-user", 396 "Config": { 397 "image": "redis:latest", 398 "port_map": [ 399 { 400 "db": 6379 401 } 402 ] 403 }, 404 "Env": { 405 "foo": "bar", 406 "baz": "pipe" 407 }, 408 "Services": [ 409 { 410 "Name": "cache-redis", 411 "PortLabel": "db", 412 "Tags": ["global", "cache"], 413 "Checks": [ 414 { 415 "Name": "alive", 416 "Type": "tcp", 417 "Command": "", 418 "Args": null, 419 "Path": "", 420 "Protocol": "", 421 "PortLabel": "", 422 "Interval": 10000000000, 423 "Timeout": 2000000000, 424 "InitialStatus": "" 425 } 426 ] 427 } 428 ], 429 "Vault": null, 430 "Templates": [ 431 { 432 "SourcePath": "local/config.conf.tpl", 433 "DestPath": "local/config.conf", 434 "EmbeddedTmpl": "", 435 "ChangeMode": "signal", 436 "ChangeSignal": "SIGUSR1", 437 "Splay": 5000000000, 438 "Perms": "" 439 } 440 ], 441 "Constraints": null, 442 "Affinities": null, 443 "Resources": { 444 "CPU": 500, 445 "MemoryMB": 256, 446 "DiskMB": 0, 447 "Networks": [ 448 { 449 "Device": "", 450 "CIDR": "", 451 "IP": "", 452 "MBits": 10, 453 "ReservedPorts": [ 454 { 455 "Label": "rpc", 456 "Value": 25566 457 } 458 ], 459 "DynamicPorts": [ 460 { 461 "Label": "db", 462 "Value": 0 463 } 464 ] 465 } 466 ] 467 }, 468 "DispatchPayload": { 469 "File": "config.json" 470 }, 471 "Meta": { 472 "foo": "bar", 473 "baz": "pipe" 474 }, 475 "KillTimeout": 5000000000, 476 "LogConfig": { 477 "MaxFiles": 10, 478 "MaxFileSizeMB": 10 479 }, 480 "Artifacts": [ 481 { 482 "GetterSource": "http://foo.com/artifact.tar.gz", 483 "GetterOptions": { 484 "checksum": "md5:c4aa853ad2215426eb7d70a21922e794" 485 }, 486 "RelativeDest": "local/" 487 } 488 ], 489 "Leader": false 490 } 491 ], 492 "EphemeralDisk": { 493 "Sticky": false, 494 "SizeMB": 300, 495 "Migrate": false 496 }, 497 "Meta": { 498 "foo": "bar", 499 "baz": "pipe" 500 } 501 } 502 ], 503 "Update": { 504 "Stagger": 10000000000, 505 "MaxParallel": 1 506 }, 507 "Periodic": { 508 "Enabled": true, 509 "Spec": "* * * * *", 510 "SpecType": "cron", 511 "ProhibitOverlap": true 512 }, 513 "ParameterizedJob": { 514 "Payload": "required", 515 "MetaRequired": ["foo"], 516 "MetaOptional": ["bar"] 517 }, 518 "Payload": null, 519 "Meta": { 520 "foo": "bar", 521 "baz": "pipe" 522 }, 523 "VaultToken": "", 524 "Status": "running", 525 "StatusDescription": "", 526 "CreateIndex": 7, 527 "ModifyIndex": 7, 528 "JobModifyIndex": 7 529 } 530 ``` 531 532 ## List Job Versions 533 534 This endpoint reads information about all versions of a job. 535 536 | Method | Path | Produces | 537 | ------ | -------------------------- | ------------------ | 538 | `GET` | `/v1/job/:job_id/versions` | `application/json` | 539 540 The table below shows this endpoint's support for 541 [blocking queries](/api-docs#blocking-queries) and 542 [required ACLs](/api-docs#acls). 543 544 | Blocking Queries | ACL Required | 545 | ---------------- | -------------------- | 546 | `YES` | `namespace:read-job` | 547 548 ### Parameters 549 550 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 551 the job file during submission). This is specified as part of the path. 552 553 ### Sample Request 554 555 ```shell-sessioncurl \ 556 https://localhost:4646/v1/job/my-job/versions 557 ``` 558 559 ### Sample Response 560 561 ```json 562 [ 563 { 564 "Stop": false, 565 "Region": "global", 566 "ID": "example", 567 "ParentID": "", 568 "Name": "example", 569 "Type": "service", 570 "Priority": 50, 571 "AllAtOnce": false, 572 "Datacenters": ["dc1"], 573 "Constraints": null, 574 "Affinities": null, 575 "TaskGroups": [ 576 { 577 "Name": "cache", 578 "Count": 1, 579 "Update": { 580 "Stagger": 0, 581 "MaxParallel": 1, 582 "HealthCheck": "checks", 583 "MinHealthyTime": 10000000000, 584 "HealthyDeadline": 300000000000, 585 "AutoRevert": false, 586 "Canary": 0 587 }, 588 "Constraints": null, 589 "Affinities": null, 590 "RestartPolicy": { 591 "Attempts": 10, 592 "Interval": 300000000000, 593 "Delay": 25000000000, 594 "Mode": "delay" 595 }, 596 "Spreads": [ 597 { 598 "Attribute": "${node.datacenter}", 599 "SpreadTarget": null, 600 "Weight": 100 601 } 602 ], 603 "Tasks": [ 604 { 605 "Name": "redis", 606 "Driver": "docker", 607 "User": "", 608 "Config": { 609 "image": "redis:3.2", 610 "port_map": [ 611 { 612 "db": 6379 613 } 614 ] 615 }, 616 "Env": null, 617 "Services": [ 618 { 619 "Name": "redis-cache", 620 "PortLabel": "db", 621 "Tags": ["global", "cache"], 622 "Checks": [ 623 { 624 "Name": "alive", 625 "Type": "tcp", 626 "Command": "", 627 "Args": null, 628 "Path": "", 629 "Protocol": "", 630 "PortLabel": "", 631 "Interval": 10000000000, 632 "Timeout": 2000000000, 633 "InitialStatus": "", 634 "TLSSkipVerify": false 635 } 636 ] 637 } 638 ], 639 "Vault": null, 640 "Templates": null, 641 "Constraints": null, 642 "Affinities": null, 643 "Spreads": null, 644 "Resources": { 645 "CPU": 500, 646 "MemoryMB": 256, 647 "DiskMB": 0, 648 "Networks": [ 649 { 650 "Device": "", 651 "CIDR": "", 652 "IP": "", 653 "MBits": 10, 654 "ReservedPorts": null, 655 "DynamicPorts": [ 656 { 657 "Label": "db", 658 "Value": 0 659 } 660 ] 661 } 662 ] 663 }, 664 "DispatchPayload": null, 665 "Meta": null, 666 "KillTimeout": 5000000000, 667 "LogConfig": { 668 "MaxFiles": 10, 669 "MaxFileSizeMB": 10 670 }, 671 "Artifacts": null, 672 "Leader": false 673 } 674 ], 675 "EphemeralDisk": { 676 "Sticky": false, 677 "SizeMB": 300, 678 "Migrate": false 679 }, 680 "Meta": null 681 } 682 ], 683 "Update": { 684 "Stagger": 10000000000, 685 "MaxParallel": 1, 686 "HealthCheck": "", 687 "MinHealthyTime": 0, 688 "HealthyDeadline": 0, 689 "AutoRevert": false, 690 "Canary": 0 691 }, 692 "Periodic": null, 693 "ParameterizedJob": null, 694 "Payload": null, 695 "Meta": null, 696 "VaultToken": "", 697 "Spreads": null, 698 "Status": "pending", 699 "StatusDescription": "", 700 "Stable": false, 701 "Version": 0, 702 "CreateIndex": 7, 703 "ModifyIndex": 7, 704 "JobModifyIndex": 7 705 } 706 ] 707 ``` 708 709 ## List Job Allocations 710 711 This endpoint reads information about a single job's allocations. 712 713 | Method | Path | Produces | 714 | ------ | ----------------------------- | ------------------ | 715 | `GET` | `/v1/job/:job_id/allocations` | `application/json` | 716 717 The table below shows this endpoint's support for 718 [blocking queries](/api-docs#blocking-queries) and 719 [required ACLs](/api-docs#acls). 720 721 | Blocking Queries | ACL Required | 722 | ---------------- | -------------------- | 723 | `YES` | `namespace:read-job` | 724 725 ### Parameters 726 727 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 728 the job file during submission). This is specified as part of the path. 729 730 - `all` `(bool: false)` - Specifies whether the list of allocations should 731 include allocations from a previously registered job with the same ID. This is 732 possible if the job is deregistered and reregistered. 733 734 ### Sample Request 735 736 ```shell-sessioncurl \ 737 https://localhost:4646/v1/job/my-job/allocations 738 ``` 739 740 ### Sample Response 741 742 ```json 743 [ 744 { 745 "ID": "ed344e0a-7290-d117-41d3-a64f853ca3c2", 746 "EvalID": "a9c5effc-2242-51b2-f1fe-054ee11ab189", 747 "Name": "example.cache[0]", 748 "NodeID": "cb1f6030-a220-4f92-57dc-7baaabdc3823", 749 "PreviousAllocation": "516d2753-0513-cfc7-57ac-2d6fac18b9dc", 750 "NextAllocation": "cd13d9b9-4f97-7184-c88b-7b451981616b", 751 "RescheduleTracker": { 752 "Events": [ 753 { 754 "PrevAllocID": "516d2753-0513-cfc7-57ac-2d6fac18b9dc", 755 "PrevNodeID": "9230cd3b-3bda-9a3f-82f9-b2ea8dedb20e", 756 "RescheduleTime": 1517434161192946200, 757 "Delay": 5000000000 758 } 759 ] 760 }, 761 "JobID": "example", 762 "TaskGroup": "cache", 763 "DesiredStatus": "run", 764 "DesiredDescription": "", 765 "ClientStatus": "running", 766 "ClientDescription": "", 767 "TaskStates": { 768 "redis": { 769 "State": "running", 770 "Failed": false, 771 "StartedAt": "2017-05-25T23:41:23.240184101Z", 772 "FinishedAt": "0001-01-01T00:00:00Z", 773 "Events": [ 774 { 775 "Type": "Received", 776 "Time": 1495755675956923000, 777 "FailsTask": false, 778 "RestartReason": "", 779 "SetupError": "", 780 "DriverError": "", 781 "ExitCode": 0, 782 "Signal": 0, 783 "Message": "", 784 "KillTimeout": 0, 785 "KillError": "", 786 "KillReason": "", 787 "StartDelay": 0, 788 "DownloadError": "", 789 "ValidationError": "", 790 "DiskLimit": 0, 791 "FailedSibling": "", 792 "VaultError": "", 793 "TaskSignalReason": "", 794 "TaskSignal": "", 795 "DriverMessage": "" 796 }, 797 { 798 "Type": "Task Setup", 799 "Time": 1495755675957466400, 800 "FailsTask": false, 801 "RestartReason": "", 802 "SetupError": "", 803 "DriverError": "", 804 "ExitCode": 0, 805 "Signal": 0, 806 "Message": "Building Task Directory", 807 "KillTimeout": 0, 808 "KillError": "", 809 "KillReason": "", 810 "StartDelay": 0, 811 "DownloadError": "", 812 "ValidationError": "", 813 "DiskLimit": 0, 814 "FailedSibling": "", 815 "VaultError": "", 816 "TaskSignalReason": "", 817 "TaskSignal": "", 818 "DriverMessage": "" 819 }, 820 { 821 "Type": "Driver", 822 "Time": 1495755675970286800, 823 "FailsTask": false, 824 "RestartReason": "", 825 "SetupError": "", 826 "DriverError": "", 827 "ExitCode": 0, 828 "Signal": 0, 829 "Message": "", 830 "KillTimeout": 0, 831 "KillError": "", 832 "KillReason": "", 833 "StartDelay": 0, 834 "DownloadError": "", 835 "ValidationError": "", 836 "DiskLimit": 0, 837 "FailedSibling": "", 838 "VaultError": "", 839 "TaskSignalReason": "", 840 "TaskSignal": "", 841 "DriverMessage": "Downloading image redis:3.2" 842 }, 843 { 844 "Type": "Started", 845 "Time": 1495755683227522000, 846 "FailsTask": false, 847 "RestartReason": "", 848 "SetupError": "", 849 "DriverError": "", 850 "ExitCode": 0, 851 "Signal": 0, 852 "Message": "", 853 "KillTimeout": 0, 854 "KillError": "", 855 "KillReason": "", 856 "StartDelay": 0, 857 "DownloadError": "", 858 "ValidationError": "", 859 "DiskLimit": 0, 860 "FailedSibling": "", 861 "VaultError": "", 862 "TaskSignalReason": "", 863 "TaskSignal": "", 864 "DriverMessage": "" 865 } 866 ] 867 } 868 }, 869 "CreateIndex": 9, 870 "ModifyIndex": 13, 871 "CreateTime": 1495755675944527600, 872 "ModifyTime": 1495755675944527600 873 } 874 ] 875 ``` 876 877 ## List Job Evaluations 878 879 This endpoint reads information about a single job's evaluations 880 881 | Method | Path | Produces | 882 | ------ | ----------------------------- | ------------------ | 883 | `GET` | `/v1/job/:job_id/evaluations` | `application/json` | 884 885 The table below shows this endpoint's support for 886 [blocking queries](/api-docs#blocking-queries) and 887 [required ACLs](/api-docs#acls). 888 889 | Blocking Queries | ACL Required | 890 | ---------------- | -------------------- | 891 | `YES` | `namespace:read-job` | 892 893 ### Parameters 894 895 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 896 the job file during submission). This is specified as part of the path. 897 898 ### Sample Request 899 900 ```shell-sessioncurl \ 901 https://localhost:4646/v1/job/my-job/evaluations 902 ``` 903 904 ### Sample Response 905 906 ```json 907 [ 908 { 909 "ID": "a9c5effc-2242-51b2-f1fe-054ee11ab189", 910 "Priority": 50, 911 "Type": "service", 912 "TriggeredBy": "job-register", 913 "JobID": "example", 914 "JobModifyIndex": 7, 915 "NodeID": "", 916 "NodeModifyIndex": 0, 917 "Status": "complete", 918 "StatusDescription": "", 919 "Wait": 0, 920 "NextEval": "", 921 "PreviousEval": "", 922 "BlockedEval": "", 923 "FailedTGAllocs": null, 924 "ClassEligibility": null, 925 "EscapedComputedClass": false, 926 "AnnotatePlan": false, 927 "QueuedAllocations": { 928 "cache": 0 929 }, 930 "SnapshotIndex": 8, 931 "CreateIndex": 8, 932 "ModifyIndex": 10 933 } 934 ] 935 ``` 936 937 ## List Job Deployments 938 939 This endpoint lists a single job's deployments 940 941 | Method | Path | Produces | 942 | ------ | ----------------------------- | ------------------ | 943 | `GET` | `/v1/job/:job_id/deployments` | `application/json` | 944 945 The table below shows this endpoint's support for 946 [blocking queries](/api-docs#blocking-queries) and 947 [required ACLs](/api-docs#acls). 948 949 | Blocking Queries | ACL Required | 950 | ---------------- | -------------------- | 951 | `YES` | `namespace:read-job` | 952 953 ### Parameters 954 955 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 956 the job file during submission). This is specified as part of the path. 957 958 - `all` `(bool: false)` - Specifies whether the list of deployments should 959 include deployments from a previously registered job with the same ID. This is 960 possible if the job is deregistered and reregistered. 961 962 ### Sample Request 963 964 ```shell-sessioncurl \ 965 https://localhost:4646/v1/job/my-job/deployments 966 ``` 967 968 ### Sample Response 969 970 ```json 971 [ 972 { 973 "ID": "85ee4a9a-339f-a921-a9ef-0550d20b2c61", 974 "JobID": "my-job", 975 "JobVersion": 1, 976 "JobModifyIndex": 19, 977 "JobCreateIndex": 7, 978 "TaskGroups": { 979 "cache": { 980 "AutoRevert": true, 981 "Promoted": false, 982 "PlacedCanaries": [ 983 "d0ad0808-2765-abf6-1e15-79fb7fe5a416", 984 "38c70cd8-81f2-1489-a328-87bb29ec0e0f" 985 ], 986 "DesiredCanaries": 2, 987 "DesiredTotal": 3, 988 "PlacedAllocs": 2, 989 "HealthyAllocs": 2, 990 "UnhealthyAllocs": 0 991 } 992 }, 993 "Status": "running", 994 "StatusDescription": "Deployment is running", 995 "CreateIndex": 21, 996 "ModifyIndex": 25 997 }, 998 { 999 "ID": "fb6070fb-4a44-e255-4e6f-8213eba3871a", 1000 "JobID": "my-job", 1001 "JobVersion": 0, 1002 "JobModifyIndex": 7, 1003 "JobCreateIndex": 7, 1004 "TaskGroups": { 1005 "cache": { 1006 "AutoRevert": true, 1007 "Promoted": false, 1008 "PlacedCanaries": null, 1009 "DesiredCanaries": 0, 1010 "DesiredTotal": 3, 1011 "PlacedAllocs": 3, 1012 "HealthyAllocs": 3, 1013 "UnhealthyAllocs": 0 1014 } 1015 }, 1016 "Status": "successful", 1017 "StatusDescription": "Deployment completed successfully", 1018 "CreateIndex": 9, 1019 "ModifyIndex": 17 1020 } 1021 ] 1022 ``` 1023 1024 ## Read Job's Most Recent Deployment 1025 1026 This endpoint returns a single job's most recent deployment. 1027 1028 | Method | Path | Produces | 1029 | ------ | ---------------------------- | ------------------ | 1030 | `GET` | `/v1/job/:job_id/deployment` | `application/json` | 1031 1032 The table below shows this endpoint's support for 1033 [blocking queries](/api-docs#blocking-queries) and 1034 [required ACLs](/api-docs#acls). 1035 1036 | Blocking Queries | ACL Required | 1037 | ---------------- | -------------------- | 1038 | `YES` | `namespace:read-job` | 1039 1040 ### Parameters 1041 1042 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1043 the job file during submission). This is specified as part of the path. 1044 1045 ### Sample Request 1046 1047 ```shell-sessioncurl \ 1048 https://localhost:4646/v1/job/my-job/deployment 1049 ``` 1050 1051 ### Sample Response 1052 1053 ```json 1054 { 1055 "ID": "85ee4a9a-339f-a921-a9ef-0550d20b2c61", 1056 "JobID": "my-job", 1057 "JobVersion": 1, 1058 "JobModifyIndex": 19, 1059 "JobCreateIndex": 7, 1060 "TaskGroups": { 1061 "cache": { 1062 "AutoRevert": true, 1063 "Promoted": false, 1064 "PlacedCanaries": [ 1065 "d0ad0808-2765-abf6-1e15-79fb7fe5a416", 1066 "38c70cd8-81f2-1489-a328-87bb29ec0e0f" 1067 ], 1068 "DesiredCanaries": 2, 1069 "DesiredTotal": 3, 1070 "PlacedAllocs": 2, 1071 "HealthyAllocs": 2, 1072 "UnhealthyAllocs": 0 1073 } 1074 }, 1075 "Status": "running", 1076 "StatusDescription": "Deployment is running", 1077 "CreateIndex": 21, 1078 "ModifyIndex": 25 1079 } 1080 ``` 1081 1082 ## Read Job Summary 1083 1084 This endpoint reads summary information about a job. 1085 1086 | Method | Path | Produces | 1087 | ------ | ------------------------- | ------------------ | 1088 | `GET` | `/v1/job/:job_id/summary` | `application/json` | 1089 1090 The table below shows this endpoint's support for 1091 [blocking queries](/api-docs#blocking-queries) and 1092 [required ACLs](/api-docs#acls). 1093 1094 | Blocking Queries | ACL Required | 1095 | ---------------- | -------------------- | 1096 | `YES` | `namespace:read-job` | 1097 1098 ### Parameters 1099 1100 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1101 the job file during submission). This is specified as part of the path. 1102 1103 ### Sample Request 1104 1105 ```shell-sessioncurl \ 1106 https://localhost:4646/v1/job/my-job/summary 1107 ``` 1108 1109 ### Sample Response 1110 1111 ```json 1112 { 1113 "JobID": "example", 1114 "Summary": { 1115 "cache": { 1116 "Queued": 0, 1117 "Complete": 0, 1118 "Failed": 0, 1119 "Running": 1, 1120 "Starting": 0, 1121 "Lost": 0 1122 } 1123 }, 1124 "Children": { 1125 "Pending": 0, 1126 "Running": 0, 1127 "Dead": 0 1128 }, 1129 "CreateIndex": 7, 1130 "ModifyIndex": 13 1131 } 1132 ``` 1133 1134 ## Update Existing Job 1135 1136 This endpoint registers a new job or updates an existing job. 1137 1138 | Method | Path | Produces | 1139 | ------ | ----------------- | ------------------ | 1140 | `POST` | `/v1/job/:job_id` | `application/json` | 1141 1142 The table below shows this endpoint's support for 1143 [blocking queries](/api-docs#blocking-queries) and 1144 [required ACLs](/api-docs#acls). 1145 1146 | Blocking Queries | ACL Required | 1147 | ---------------- | --------------------------------------------------------------------------------- | 1148 | `NO` | `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 1149 1150 ### Parameters 1151 1152 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1153 the job file during submission). This is specified as part of the path. 1154 1155 - `Job` `(Job: <required>)` - Specifies the JSON definition of the job. 1156 1157 - `EnforceIndex` `(bool: false)` - If set, the job will only be registered if the 1158 passed `JobModifyIndex` matches the current job's index. If the index is zero, 1159 the register only occurs if the job is new. This paradigm allows check-and-set 1160 style job updating. 1161 1162 - `JobModifyIndex` `(int: 0)` - Specifies the `JobModifyIndex` to enforce the 1163 current job is at. 1164 1165 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 1166 will be overridden. This allows a job to be registered when it would be denied 1167 by policy. 1168 1169 ### Sample Payload 1170 1171 ```javascript 1172 { 1173 "Job": { 1174 // ... 1175 }, 1176 "EnforceIndex": true, 1177 "JobModifyIndex": 4 1178 } 1179 ``` 1180 1181 ### Sample Request 1182 1183 ```shell-sessioncurl \ 1184 --request POST \ 1185 --data @payload.json \ 1186 https://localhost:4646/v1/job/my-job 1187 ``` 1188 1189 ### Sample Response 1190 1191 ```json 1192 { 1193 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1194 "EvalCreateIndex": 35, 1195 "JobModifyIndex": 34 1196 } 1197 ``` 1198 1199 ## Dispatch Job 1200 1201 This endpoint dispatches a new instance of a parameterized job. 1202 1203 | Method | Path | Produces | 1204 | ------ | -------------------------- | ------------------ | 1205 | `POST` | `/v1/job/:job_id/dispatch` | `application/json` | 1206 1207 The table below shows this endpoint's support for 1208 [blocking queries](/api-docs#blocking-queries) and 1209 [required ACLs](/api-docs#acls). 1210 1211 | Blocking Queries | ACL Required | 1212 | ---------------- | ------------------------ | 1213 | `NO` | `namespace:dispatch-job` | 1214 1215 ### Parameters 1216 1217 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified 1218 in the job file during submission). This is specified as part of the path. 1219 1220 - `Payload` `(string: "")` - Specifies a base64 encoded string containing the 1221 payload. This is limited to 15 KB. 1222 1223 - `Meta` `(meta<string|string>: nil)` - Specifies arbitrary metadata to pass to 1224 the job. 1225 1226 ### Sample Payload 1227 1228 ```json 1229 { 1230 "Payload": "A28C3==", 1231 "Meta": { 1232 "key": "Value" 1233 } 1234 } 1235 ``` 1236 1237 ### Sample Request 1238 1239 ```shell-sessioncurl \ 1240 --request POST \ 1241 --data @payload.json \ 1242 https://localhost:4646/v1/job/my-job/dispatch 1243 ``` 1244 1245 ### Sample Response 1246 1247 ```json 1248 { 1249 "Index": 13, 1250 "JobCreateIndex": 12, 1251 "EvalCreateIndex": 13, 1252 "EvalID": "e5f55fac-bc69-119d-528a-1fc7ade5e02c", 1253 "DispatchedJobID": "example/dispatch-1485408778-81644024" 1254 } 1255 ``` 1256 1257 ## Revert to older Job Version 1258 1259 This endpoint reverts the job to an older version. 1260 1261 | Method | Path | Produces | 1262 | ------ | ------------------------ | ------------------ | 1263 | `POST` | `/v1/job/:job_id/revert` | `application/json` | 1264 1265 The table below shows this endpoint's support for 1266 [blocking queries](/api-docs#blocking-queries) and 1267 [required ACLs](/api-docs#acls). 1268 1269 | Blocking Queries | ACL Required | 1270 | ---------------- | ---------------------- | 1271 | `NO` | `namespace:submit-job` | 1272 1273 ### Parameters 1274 1275 - `JobID` `(string: <required>)` - Specifies the ID of the job (as specified 1276 in the job file during submission). This is specified as part of the path. 1277 1278 - `JobVersion` `(integer: 0)` - Specifies the job version to revert to. 1279 1280 - `EnforcePriorVersion` `(integer: nil)` - Optional value specifying the current 1281 job's version. This is checked and acts as a check-and-set value before 1282 reverting to the specified job. 1283 1284 - `ConsulToken` `(string:"")` - Optional value specifying the [consul token](/docs/commands/job/revert) 1285 used for Consul [service identity polity authentication checking](/docs/configuration/consul#allow_unauthenticated). 1286 1287 - `VaultToken` `(string: "")` - Optional value specifying the [vault token](/docs/commands/job/revert) 1288 used for Vault [policy authentication checking](/docs/configuration/vault#allow_unauthenticated). 1289 1290 ### Sample Payload 1291 1292 ```json 1293 { 1294 "JobID": "my-job", 1295 "JobVersion": 2 1296 } 1297 ``` 1298 1299 ### Sample Request 1300 1301 ```shell-sessioncurl \ 1302 --request POST \ 1303 --data @payload.json \ 1304 https://localhost:4646/v1/job/my-job/revert 1305 ``` 1306 1307 ### Sample Response 1308 1309 ```json 1310 { 1311 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1312 "EvalCreateIndex": 35, 1313 "JobModifyIndex": 34 1314 } 1315 ``` 1316 1317 ## Set Job Stability 1318 1319 This endpoint sets the job's stability. 1320 1321 | Method | Path | Produces | 1322 | ------ | ------------------------ | ------------------ | 1323 | `POST` | `/v1/job/:job_id/stable` | `application/json` | 1324 1325 The table below shows this endpoint's support for 1326 [blocking queries](/api-docs#blocking-queries) and 1327 [required ACLs](/api-docs#acls). 1328 1329 | Blocking Queries | ACL Required | 1330 | ---------------- | ---------------------- | 1331 | `NO` | `namespace:submit-job` | 1332 1333 ### Parameters 1334 1335 - `JobID` `(string: <required>)` - Specifies the ID of the job (as specified 1336 in the job file during submission). This is specified as part of the path. 1337 1338 - `JobVersion` `(integer: 0)` - Specifies the job version to set the stability on. 1339 1340 - `Stable` `(bool: false)` - Specifies whether the job should be marked as 1341 stable or not. 1342 1343 ### Sample Payload 1344 1345 ```json 1346 { 1347 "JobID": "my-job", 1348 "JobVersion": 2, 1349 "Stable": true 1350 } 1351 ``` 1352 1353 ### Sample Request 1354 1355 ```shell-sessioncurl \ 1356 --request POST \ 1357 --data @payload.json \ 1358 https://localhost:4646/v1/job/my-job/stable 1359 ``` 1360 1361 ### Sample Response 1362 1363 ```json 1364 { 1365 "JobModifyIndex": 34 1366 } 1367 ``` 1368 1369 ## Create Job Evaluation 1370 1371 This endpoint creates a new evaluation for the given job. This can be used to 1372 force run the scheduling logic if necessary. Since Nomad 0.8.4, this endpoint 1373 supports a JSON payload with additional options. Support for calling this end point 1374 without a JSON payload will be removed in Nomad 0.9. 1375 1376 | Method | Path | Produces | 1377 | ------ | -------------------------- | ------------------ | 1378 | `POST` | `/v1/job/:job_id/evaluate` | `application/json` | 1379 1380 The table below shows this endpoint's support for 1381 [blocking queries](/api-docs#blocking-queries) and 1382 [required ACLs](/api-docs#acls). 1383 1384 | Blocking Queries | ACL Required | 1385 | ---------------- | -------------------- | 1386 | `NO` | `namespace:read-job` | 1387 1388 ### Parameters 1389 1390 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1391 the job file during submission). This is specified as part of the path. 1392 1393 - `JobID` `(string: <required>)` - Specify the ID of the job in the JSON payload 1394 1395 - `EvalOptions` `(<optional>)` - Specify additional options to be used during the forced evaluation. 1396 - `ForceReschedule` `(bool: false)` - If set, failed allocations of the job are rescheduled 1397 immediately. This is useful for operators to force immediate placement even if the failed allocations are past 1398 their reschedule limit, or are delayed by several hours because the allocation's reschedule policy has exponential delay. 1399 1400 ### Sample Payload 1401 1402 ```json 1403 { 1404 "JobID": "my-job", 1405 "EvalOptions": { 1406 "ForceReschedule": true 1407 } 1408 } 1409 ``` 1410 1411 ### Sample Request 1412 1413 ```shell-sessioncurl \ 1414 --request POST \ 1415 -d @sample.json \ 1416 https://localhost:4646/v1/job/my-job/evaluate 1417 ``` 1418 1419 ### Sample Response 1420 1421 ```json 1422 { 1423 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1424 "EvalCreateIndex": 35, 1425 "JobModifyIndex": 34 1426 } 1427 ``` 1428 1429 ## Create Job Plan 1430 1431 This endpoint invokes a dry-run of the scheduler for the job. 1432 1433 | Method | Path | Produces | 1434 | ------ | ---------------------- | ------------------ | 1435 | `POST` | `/v1/job/:job_id/plan` | `application/json` | 1436 1437 The table below shows this endpoint's support for 1438 [blocking queries](/api-docs#blocking-queries) and 1439 [required ACLs](/api-docs#acls). 1440 1441 | Blocking Queries | ACL Required | 1442 | ---------------- | --------------------------------------------------------------------------------- | 1443 | `NO` | `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 1444 1445 ### Parameters 1446 1447 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1448 - the job file during submission). This is specified as part of the path. 1449 1450 - `Job` `(string: <required>)` - Specifies the JSON definition of the job. 1451 1452 - `Diff` `(bool: false)` - Specifies whether the diff structure between the 1453 submitted and server side version of the job should be included in the 1454 response. 1455 1456 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 1457 will be overridden. This allows a job to be registered when it would be denied 1458 by policy. 1459 1460 ### Sample Payload 1461 1462 ```json 1463 { 1464 "Job": "...", 1465 "Diff": true, 1466 "PolicyOverride": false 1467 } 1468 ``` 1469 1470 ### Sample Request 1471 1472 ```shell-sessioncurl \ 1473 --request POST \ 1474 --data @payload.json \ 1475 https://localhost:4646/v1/job/my-job/plan 1476 ``` 1477 1478 ### Sample Response 1479 1480 ```json 1481 { 1482 "Index": 0, 1483 "NextPeriodicLaunch": "0001-01-01T00:00:00Z", 1484 "Warnings": "", 1485 "Diff": { 1486 "Type": "Added", 1487 "TaskGroups": [ 1488 { 1489 "Updates": { 1490 "create": 1 1491 }, 1492 "Type": "Added", 1493 "Tasks": [ 1494 { 1495 "Type": "Added", 1496 "Objects": ["..."], 1497 "Name": "redis", 1498 "Fields": [ 1499 { 1500 "Type": "Added", 1501 "Old": "", 1502 "New": "docker", 1503 "Name": "Driver", 1504 "Annotations": null 1505 }, 1506 { 1507 "Type": "Added", 1508 "Old": "", 1509 "New": "5000000000", 1510 "Name": "KillTimeout", 1511 "Annotations": null 1512 } 1513 ], 1514 "Annotations": ["forces create"] 1515 } 1516 ], 1517 "Objects": ["..."], 1518 "Name": "cache", 1519 "Fields": ["..."] 1520 } 1521 ], 1522 "Objects": [ 1523 { 1524 "Type": "Added", 1525 "Objects": null, 1526 "Name": "Datacenters", 1527 "Fields": ["..."] 1528 }, 1529 { 1530 "Type": "Added", 1531 "Objects": null, 1532 "Name": "Constraint", 1533 "Fields": ["..."] 1534 }, 1535 { 1536 "Type": "Added", 1537 "Objects": null, 1538 "Name": "Update", 1539 "Fields": ["..."] 1540 } 1541 ], 1542 "ID": "example", 1543 "Fields": ["..."] 1544 }, 1545 "CreatedEvals": [ 1546 { 1547 "ModifyIndex": 0, 1548 "CreateIndex": 0, 1549 "SnapshotIndex": 0, 1550 "AnnotatePlan": false, 1551 "EscapedComputedClass": false, 1552 "NodeModifyIndex": 0, 1553 "NodeID": "", 1554 "JobModifyIndex": 0, 1555 "JobID": "example", 1556 "TriggeredBy": "job-register", 1557 "Type": "batch", 1558 "Priority": 50, 1559 "ID": "312e6a6d-8d01-0daf-9105-14919a66dba3", 1560 "Status": "blocked", 1561 "StatusDescription": "created to place remaining allocations", 1562 "Wait": 0, 1563 "NextEval": "", 1564 "PreviousEval": "80318ae4-7eda-e570-e59d-bc11df134817", 1565 "BlockedEval": "", 1566 "FailedTGAllocs": null, 1567 "ClassEligibility": { 1568 "v1:7968290453076422024": true 1569 } 1570 } 1571 ], 1572 "JobModifyIndex": 0, 1573 "FailedTGAllocs": { 1574 "cache": { 1575 "CoalescedFailures": 3, 1576 "AllocationTime": 46415, 1577 "Scores": null, 1578 "NodesEvaluated": 1, 1579 "NodesFiltered": 0, 1580 "NodesAvailable": { 1581 "dc1": 1 1582 }, 1583 "ClassFiltered": null, 1584 "ConstraintFiltered": null, 1585 "NodesExhausted": 1, 1586 "ClassExhausted": null, 1587 "DimensionExhausted": { 1588 "cpu": 1 1589 } 1590 } 1591 }, 1592 "Annotations": { 1593 "DesiredTGUpdates": { 1594 "cache": { 1595 "DestructiveUpdate": 0, 1596 "InPlaceUpdate": 0, 1597 "Stop": 0, 1598 "Migrate": 0, 1599 "Place": 11, 1600 "Ignore": 0 1601 } 1602 } 1603 } 1604 } 1605 ``` 1606 1607 #### Field Reference 1608 1609 - `Diff` - A diff structure between the submitted job and the server side 1610 version. The top-level object is a Job Diff which contains Task Group Diffs, 1611 which in turn contain Task Diffs. Each of these objects then has Object and 1612 Field Diff structures embedded. 1613 1614 - `NextPeriodicLaunch` - If the job being planned is periodic, this field will 1615 include the next launch time for the job. 1616 1617 - `CreatedEvals` - A set of evaluations that were created as a result of the 1618 dry-run. These evaluations can signify a follow-up rolling update evaluation 1619 or a blocked evaluation. 1620 1621 - `JobModifyIndex` - The `JobModifyIndex` of the server side version of this job. 1622 1623 - `FailedTGAllocs` - A set of metrics to understand any allocation failures that 1624 occurred for the Task Group. 1625 1626 - `Annotations` - Annotations include the `DesiredTGUpdates`, which tracks what 1627 - the scheduler would do given enough resources for each Task Group. 1628 1629 ## Force New Periodic Instance 1630 1631 This endpoint forces a new instance of the periodic job. A new instance will be 1632 created even if it violates the job's 1633 [`prohibit_overlap`](/docs/job-specification/periodic#prohibit_overlap) 1634 settings. As such, this should be only used to immediately run a periodic job. 1635 1636 | Method | Path | Produces | 1637 | ------ | -------------------------------- | ------------------ | 1638 | `POST` | `/v1/job/:job_id/periodic/force` | `application/json` | 1639 1640 The table below shows this endpoint's support for 1641 [blocking queries](/api-docs#blocking-queries) and 1642 [required ACLs](/api-docs#acls). 1643 1644 | Blocking Queries | ACL Required | 1645 | ---------------- | ---------------------- | 1646 | `NO` | `namespace:submit-job` | 1647 1648 ### Parameters 1649 1650 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1651 the job file during submission). This is specified as part of the path. 1652 1653 ### Sample Request 1654 1655 ```shell-sessioncurl \ 1656 --request POST \ 1657 https://localhost:4646/v1/job/my-job/periodic/force 1658 ``` 1659 1660 ### Sample Response 1661 1662 ```json 1663 { 1664 "EvalCreateIndex": 7, 1665 "EvalID": "57983ddd-7fcf-3e3a-fd24-f699ccfb36f4" 1666 } 1667 ``` 1668 1669 ## Stop a Job 1670 1671 This endpoint deregisters a job, and stops all allocations part of it. 1672 1673 | Method | Path | Produces | 1674 | -------- | ----------------- | ------------------ | 1675 | `DELETE` | `/v1/job/:job_id` | `application/json` | 1676 1677 The table below shows this endpoint's support for 1678 [blocking queries](/api-docs#blocking-queries) and 1679 [required ACLs](/api-docs#acls). 1680 1681 | Blocking Queries | ACL Required | 1682 | ---------------- | ---------------------- | 1683 | `NO` | `namespace:submit-job` | 1684 1685 ### Parameters 1686 1687 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1688 the job file during submission). This is specified as part of the path. 1689 1690 - `purge` `(bool: false)` - Specifies that the job should stopped and purged 1691 immediately. This means the job will not be queryable after being stopped. If 1692 not set, the job will be purged by the garbage collector. 1693 1694 ### Sample Request 1695 1696 ```shell-sessioncurl \ 1697 --request DELETE \ 1698 https://localhost:4646/v1/job/my-job?purge=true 1699 ``` 1700 1701 ### Sample Response 1702 1703 ```json 1704 { 1705 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1706 "EvalCreateIndex": 35, 1707 "JobModifyIndex": 34 1708 } 1709 ``` 1710 1711 ## Read Job Scale Status <sup>Beta</sup> 1712 1713 This endpoint reads scale information about a job. 1714 1715 | Method | Path | Produces | 1716 | ------ | ----------------------- | ------------------ | 1717 | `GET` | `/v1/job/:job_id/scale` | `application/json` | 1718 1719 The table below shows this endpoint's support for 1720 [blocking queries](/api-docs#blocking-queries) and 1721 [required ACLs](/api-docs#acls). 1722 1723 | Blocking Queries | ACL Required | 1724 | ---------------- | ---------------------------------------------------- | 1725 | `YES` | `namespace:read-job-scaling` or `namespace:read-job` | 1726 1727 ### Parameters 1728 1729 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1730 the job file during submission). This is specified as part of the path. 1731 1732 ### Sample Request 1733 1734 ```shell-sessioncurl \ 1735 https://localhost:4646/v1/job/my-job/scale 1736 ``` 1737 1738 ### Sample Response 1739 1740 ```json 1741 { 1742 "JobCreateIndex": 10, 1743 "JobID": "example", 1744 "JobModifyIndex": 18, 1745 "JobStopped": false, 1746 "TaskGroups": { 1747 "cache": { 1748 "Desired": 1, 1749 "Events": null, 1750 "Healthy": 1, 1751 "Placed": 1, 1752 "Running": 0, 1753 "Unhealthy": 0 1754 } 1755 } 1756 } 1757 ``` 1758 1759 ## Scale Task Group <sup>Beta</sup> 1760 1761 This endpoint performs a scaling action against a job. 1762 Currently, this endpoint supports scaling the count for a task group. 1763 1764 | Method | Path | Produces | 1765 | ------ | ----------------------- | ------------------ | 1766 | `POST` | `/v1/job/:job_id/scale` | `application/json` | 1767 1768 The table below shows this endpoint's support for 1769 [blocking queries](/api-docs#blocking-queries) and 1770 [required ACLs](/api-docs#acls). 1771 1772 | Blocking Queries | ACL Required | 1773 | ---------------- | ---------------------------------------------------------------------------------------------------------- | 1774 | `NO` | `namespace:scale-job` or `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 1775 1776 ### Parameters 1777 1778 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1779 the job file during submission). This is specified as part of the path. 1780 1781 - `Count` `(int: <optional>)` - Specifies the new task group count. 1782 1783 - `Target` `(json: required)` - JSON map containing the target of the scaling operation. 1784 Must contain a field `Group` with the name of the task group that is the target of this scaling action. 1785 1786 - `Reason` `(string: <optional>)` - Description of the scale action, persisted as part of the scaling event. 1787 Indicates information or reason for scaling; one of `Reason` or `Error` must be provided. 1788 1789 - `Error` `(string: <optional>)` - Description of the scale action, persisted as part of the scaling event. 1790 Indicates an error state preventing scaling; one of `Reason` or `Error` must be provided. 1791 1792 - `Meta` `(json: <optional>)` - JSON block that is persisted as part of the scaling event. 1793 1794 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 1795 will be overridden. This allows a job to be scaled when it would be denied 1796 by policy. 1797 1798 ### Sample Payload 1799 1800 ```javascript 1801 { 1802 "Count": 5, 1803 "Meta": { 1804 "metrics": [ 1805 "cpu", 1806 "memory" 1807 ] 1808 }, 1809 "Reason": "metric did not satisfy SLA", 1810 "Target": { 1811 "Group": "cache" 1812 } 1813 } 1814 ``` 1815 1816 ### Sample Request 1817 1818 ```shell-sessioncurl \ 1819 --request POST \ 1820 --data @payload.json \ 1821 https://localhost:4646/v1/job/example/scale 1822 ``` 1823 1824 ### Sample Response 1825 1826 This is the same payload as returned by job update. 1827 `EvalCreateIndex` and `EvalID` will only be present if the scaling operation resulted in the creation of an evaluation. 1828 1829 ```json 1830 { 1831 "EvalCreateIndex": 45, 1832 "EvalID": "116f3ede-f6a5-f6e7-2d0e-1fda136390f0", 1833 "Index": 45, 1834 "JobModifyIndex": 44, 1835 "KnownLeader": false, 1836 "LastContact": 0, 1837 "Warnings": "" 1838 } 1839 ```