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