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