github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/website/source/api/json-jobs.html.md (about)

     1  ---
     2  layout: api
     3  page_title: JSON Job Specification - HTTP API
     4  sidebar_current: api-json-jobs
     5  description: |-
     6    Jobs can also be specified via the HTTP API using a JSON format. This guide
     7    discusses the job specification in JSON format.
     8  ---
     9  
    10  # JSON Job Specification
    11  
    12  This guide covers the JSON syntax for submitting jobs to Nomad. A useful command
    13  for generating valid JSON versions of HCL jobs is:
    14  
    15  ```shell
    16  $ nomad run -output my-job.nomad
    17  ```
    18  
    19  ## Syntax
    20  
    21  Below is the JSON representation of the job outputted by `$ nomad init`:
    22  
    23  ```json
    24  {
    25      "Job": {
    26          "ID": "example",
    27          "Name": "example",
    28          "Type": "service",
    29          "Priority": 50,
    30          "Datacenters": [
    31              "dc1"
    32          ],
    33          "TaskGroups": [{
    34              "Name": "cache",
    35              "Count": 1,
    36              "Tasks": [{
    37                  "Name": "redis",
    38                  "Driver": "docker",
    39                  "User": "",
    40                  "Config": {
    41                      "image": "redis:3.2",
    42                      "port_map": [{
    43                          "db": 6379
    44                      }]
    45                  },
    46                  "Services": [{
    47                      "Id": "",
    48                      "Name": "redis-cache",
    49                      "Tags": [
    50                          "global",
    51                          "cache"
    52                      ],
    53                      "PortLabel": "db",
    54                      "AddressMode": "",
    55                      "Checks": [{
    56                          "Id": "",
    57                          "Name": "alive",
    58                          "Type": "tcp",
    59                          "Command": "",
    60                          "Args": null,
    61                          "Header": {},
    62                          "Method": "",
    63                          "Path": "",
    64                          "Protocol": "",
    65                          "PortLabel": "",
    66                          "Interval": 10000000000,
    67                          "Timeout": 2000000000,
    68                          "InitialStatus": "",
    69                          "TLSSkipVerify": false,
    70                          "CheckRestart": {
    71                              "Limit": 3,
    72                              "Grace": 30000000000,
    73                              "IgnoreWarnings": false
    74                          }
    75                      }]
    76                  }],
    77                  "Resources": {
    78                      "CPU": 500,
    79                      "MemoryMB": 256,
    80                      "Networks": [{
    81                          "Device": "",
    82                          "CIDR": "",
    83                          "IP": "",
    84                          "MBits": 10,
    85                          "DynamicPorts": [{
    86                              "Label": "db",
    87                              "Value": 0
    88                          }]
    89                      }]
    90                  },
    91                  "Leader": false
    92              }],
    93              "RestartPolicy": {
    94                  "Interval": 1800000000000,
    95                  "Attempts": 2,
    96                  "Delay": 15000000000,
    97                  "Mode": "fail"
    98              },
    99              "ReschedulePolicy": {
   100                  "Interval": 300000000000,
   101                  "Attempts": 10,
   102              },
   103              "EphemeralDisk": {
   104                  "SizeMB": 300
   105              }
   106          }],
   107          "Update": {
   108              "MaxParallel": 1,
   109              "MinHealthyTime": 10000000000,
   110              "HealthyDeadline": 180000000000,
   111              "AutoRevert": false,
   112              "Canary": 0
   113          }
   114      }
   115  }
   116  ```
   117  
   118  The example JSON could be submitted as a job using the following:
   119  
   120  ```text
   121  $ curl -XPUT -d @example.json http://127.0.0.1:4646/v1/job/example
   122  {
   123    "EvalID": "5d6ded54-0b2a-8858-6583-be5f476dec9d",
   124    "EvalCreateIndex": 12,
   125    "JobModifyIndex": 11,
   126    "Warnings": "",
   127    "Index": 12,
   128    "LastContact": 0,
   129    "KnownLeader": false
   130  }
   131  ```
   132  
   133  ## Syntax Reference
   134  
   135  Following is a syntax reference for the possible keys that are supported and
   136  their default values if any for each type of object.
   137  
   138  ### Job
   139  
   140  The `Job` object supports the following keys:
   141  
   142  - `AllAtOnce` - Controls whether the scheduler can make partial placements if
   143    optimistic scheduling resulted in an oversubscribed node. This does not
   144    control whether all allocations for the job, where all would be the desired
   145    count for each task group, must be placed atomically. This should only be
   146    used for special circumstances. Defaults to `false`.
   147  
   148  - `Constraints` - A list to define additional constraints where a job can be
   149    run. See the constraint reference for more details.
   150  
   151  - `Datacenters` - A list of datacenters in the region which are eligible
   152    for task placement. This must be provided, and does not have a default.
   153  
   154  - `TaskGroups` - A list to define additional task groups. See the task group
   155    reference for more details.
   156  
   157  - `Meta` - Annotates the job with opaque metadata.
   158  
   159  - `Namespace` - The namespace to execute the job in, defaults to "default".
   160    Values other than default are not allowed in non-Enterprise versions of Nomad.
   161  
   162  - `ParameterizedJob` - Specifies the job as a parameterized job such that it can
   163    be dispatched against. The `ParamaterizedJob` object supports the following
   164    attributes:
   165  
   166    - `MetaOptional` - Specifies the set of metadata keys that may be provided
   167      when dispatching against the job as a string array.
   168  
   169    - `MetaRequired` - Specifies the set of metadata keys that must be provided
   170      when dispatching against the job as a string array.
   171  
   172    - `Payload` - Specifies the requirement of providing a payload when
   173      dispatching against the parameterized job. The options for this field are
   174      "optional", "required" and "forbidden". The default value is "optional".
   175  
   176  - `Payload` - The payload may not be set when submitting a job but may appear in
   177    a dispatched job. The `Payload` will be a base64 encoded string containing the
   178    payload that the job was dispatched with. The `payload` has a **maximum size
   179    of 16 KiB**.
   180  
   181  - `Priority` - Specifies the job priority which is used to prioritize
   182    scheduling and access to resources. Must be between 1 and 100 inclusively,
   183    and defaults to 50.
   184  
   185  - `Region` - The region to run the job in, defaults to "global".
   186  
   187  - `Type` - Specifies the job type and switches which scheduler
   188    is used. Nomad provides the `service`, `system` and `batch` schedulers,
   189    and defaults to `service`. To learn more about each scheduler type visit
   190    [here](/docs/runtime/schedulers.html)
   191  
   192  - `Update` - Specifies an update strategy to be applied to all task groups
   193    within the job. When specified both at the job level and the task group level,
   194    the update blocks are merged with the task group's taking precedence. For more
   195    details on the update stanza, please see below.
   196  
   197  -   `Periodic` - `Periodic` allows the job to be scheduled at fixed times, dates
   198      or intervals. The periodic expression is always evaluated in the UTC
   199      timezone to ensure consistent evaluation when Nomad Servers span multiple
   200      time zones. The `Periodic` object is optional and supports the following attributes:
   201  
   202      - `Enabled` - `Enabled` determines whether the periodic job will spawn child
   203      jobs.
   204  
   205      - `TimeZone` - Specifies the time zone to evaluate the next launch interval
   206        against. This is useful when wanting to account for day light savings in
   207        various time zones. The time zone must be parsable by Golang's
   208        [LoadLocation](https://golang.org/pkg/time/#LoadLocation). The default is
   209        UTC.
   210  
   211      - `SpecType` - `SpecType` determines how Nomad is going to interpret the
   212        periodic expression. `cron` is the only supported `SpecType` currently.
   213  
   214      - `Spec` - A cron expression configuring the interval the job is launched
   215      at. Supports predefined expressions such as "@daily" and "@weekly" See
   216      [here](https://github.com/gorhill/cronexpr#implementation) for full
   217      documentation of supported cron specs and the predefined expressions.
   218  
   219      - <a id="prohibit_overlap">`ProhibitOverlap`</a> - `ProhibitOverlap` can
   220        be set to true to enforce that the periodic job doesn't spawn a new
   221        instance of the job if any of the previous jobs are still running. It is
   222        defaulted to false.
   223  
   224      An example `periodic` block:
   225  
   226      ```json
   227      {
   228        "Periodic": {
   229            "Spec": "*/15 - *",
   230            "TimeZone": "Europe/Berlin",
   231            "SpecType": "cron",
   232            "Enabled": true,
   233            "ProhibitOverlap": true
   234        }
   235      }
   236      ```
   237  
   238  - `ReschedulePolicy` - Specifies a reschedule policy to be applied to all task groups
   239    within the job. When specified both at the job level and the task group level,
   240    the reschedule blocks are merged, with the task group's taking precedence. For more
   241    details on `ReschedulePolicy`, please see below.
   242  
   243  ### Task Group
   244  
   245  `TaskGroups` is a list of `TaskGroup` objects, each supports the following
   246  attributes:
   247  
   248  - `Constraints` - This is a list of `Constraint` objects. See the constraint
   249    reference for more details.
   250  
   251  - `Count` - Specifies the number of the task groups that should
   252    be running. Must be non-negative, defaults to one.
   253  
   254  - `Meta` - A key-value map that annotates the task group with opaque metadata.
   255  
   256  - `Name` - The name of the task group. Must be specified.
   257  
   258  - `RestartPolicy` - Specifies the restart policy to be applied to tasks in this group.
   259    If omitted, a default policy for batch and non-batch jobs is used based on the
   260    job type. See the [restart policy reference](#restart_policy) for more details.
   261  
   262  - `ReschedulePolicy` - Specifies the reschedule policy to be applied to tasks in this group.
   263    If omitted, a default policy is used for batch and service jobs. System jobs are not eligible
   264    for rescheduling. See the [reschedule policy reference](#reschedule_policy) for more details.
   265  
   266  - `EphemeralDisk` - Specifies the group's ephemeral disk requirements. See the
   267    [ephemeral disk reference](#ephemeral_disk) for more details.
   268  
   269  - `Update` - Specifies an update strategy to be applied to all task groups
   270    within the job. When specified both at the job level and the task group level,
   271    the update blocks are merged with the task group's taking precedence. For more
   272    details on the update stanza, please see below.
   273  
   274  - `Tasks` - A list of `Task` object that are part of the task group.
   275  
   276  ### Task
   277  
   278  The `Task` object supports the following keys:
   279  
   280  - `Artifacts` - `Artifacts` is a list of `Artifact` objects which define
   281    artifacts to be downloaded before the task is run. See the artifacts
   282    reference for more details.
   283  
   284  - `Config` - A map of key-value configuration passed into the driver
   285    to start the task. The details of configurations are specific to
   286    each driver.
   287  
   288  - `Constraints` - This is a list of `Constraint` objects. See the constraint
   289    reference for more details.
   290  
   291  - `DispatchPayload` - Configures the task to have access to dispatch payloads.
   292    The `DispatchPayload` object supports the following attributes:
   293  
   294    - `File` - Specifies the file name to write the content of dispatch payload
   295      to. The file is written relative to the task's local directory.
   296  
   297  - `Driver` - Specifies the task driver that should be used to run the
   298    task. See the [driver documentation](/docs/drivers/index.html) for what
   299    is available. Examples include `docker`, `qemu`, `java`, and `exec`.
   300  
   301  -   `Env` - A map of key-value representing environment variables that
   302      will be passed along to the running process. Nomad variables are
   303      interpreted when set in the environment variable values. See the table of
   304      interpreted variables [here](/docs/runtime/interpolation.html).
   305  
   306      For example the below environment map will be reinterpreted:
   307  
   308      ```json
   309      {
   310        "Env": {
   311          "NODE_CLASS" : "${nomad.class}"
   312        }
   313      }
   314      ```
   315  
   316  - `KillSignal` - Specifies a configurable kill signal for a task, where the
   317    default is SIGINT. Note that this is only supported for drivers which accept
   318    sending signals (currently `docker`, `exec`, `raw_exec`, and `java` drivers).
   319  
   320  - `KillTimeout` - `KillTimeout` is a time duration in nanoseconds. It can be
   321    used to configure the time between signaling a task it will be killed and
   322    actually killing it. Drivers first sends a task the `SIGINT` signal and then
   323    sends `SIGTERM` if the task doesn't die after the `KillTimeout` duration has
   324    elapsed. The default `KillTimeout` is 5 seconds.
   325  
   326  - `Leader` - Specifies whether the task is the leader task of the task group. If
   327    set to true, when the leader task completes, all other tasks within the task
   328    group will be gracefully shutdown.
   329  
   330  - `LogConfig` - This allows configuring log rotation for the `stdout` and `stderr`
   331    buffers of a Task. See the log rotation reference below for more details.
   332  
   333  - `Meta` - Annotates the task group with opaque metadata.
   334  
   335  - `Name` - The name of the task. This field is required.
   336  
   337  - `Resources` - Provides the resource requirements of the task.
   338    See the resources reference for more details.
   339  
   340  - `Services` - `Services` is a list of `Service` objects. Nomad integrates with
   341    Consul for service discovery. A `Service` object represents a routable and
   342    discoverable service on the network. Nomad automatically registers when a task
   343    is started and de-registers it when the task transitions to the dead state.
   344    [Click here](/docs/service-discovery/index.html) to learn more about
   345    services. Below is the fields in the `Service` object:
   346  
   347       - `Name`: An explicit name for the Service. Nomad will replace `${JOB}`,
   348         `${TASKGROUP}` and `${TASK}` by the name of the job, task group or task,
   349         respectively. `${BASE}` expands to the equivalent of
   350         `${JOB}-${TASKGROUP}-${TASK}`, and is the default name for a Service.
   351         Each service defined for a given task must have a distinct name, so if
   352         a task has multiple services only one of them can use the default name
   353         and the others must be explicitly named. Names must adhere to
   354         [RFC-1123 ยง2.1](https://tools.ietf.org/html/rfc1123#section-2) and are
   355         limited to alphanumeric and hyphen characters (i.e. `[a-z0-9\-]`), and be
   356         less than 64 characters in length.
   357  
   358       - `Tags`: A list of string tags associated with this Service. String
   359         interpolation is supported in tags.
   360  
   361       - `PortLabel`: `PortLabel` is an optional string and is used to associate
   362         a port with the service.  If specified, the port label must match one
   363         defined in the resources block.  This could be a label of either a
   364         dynamic or a static port.
   365  
   366       - `AddressMode`: Specifies what address (host or driver-specific) this
   367         service should advertise.  This setting is supported in Docker since
   368         Nomad 0.6 and rkt since Nomad 0.7. Valid options are:
   369  
   370         - `auto` - Allows the driver to determine whether the host or driver
   371           address should be used. Defaults to `host` and only implemented by
   372  	 Docker. If you use a Docker network plugin such as weave, Docker will
   373           automatically use its address.
   374  
   375         - `driver` - Use the IP specified by the driver, and the port specified
   376           in a port map. A numeric port may be specified since port maps aren't
   377  	 required by all network plugins. Useful for advertising SDN and
   378           overlay network addresses. Task will fail if driver network cannot be
   379           determined. Only implemented for Docker and rkt.
   380  
   381         - `host` - Use the host IP and port.
   382  
   383       - `Checks`: `Checks` is an array of check objects. A check object defines a
   384         health check associated with the service. Nomad supports the `script`,
   385         `http` and `tcp` Consul Checks. Script checks are not supported for the
   386         qemu driver since the Nomad client doesn't have access to the file system
   387         of a task using the Qemu driver.
   388  
   389           - `Type`:  This indicates the check types supported by Nomad. Valid
   390             options are currently `script`, `http` and `tcp`.
   391  
   392           - `Name`: The name of the health check.
   393  
   394  	 - `AddressMode`: Same as `AddressMode` on `Service`.  Unlike services,
   395  	   checks do not have an `auto` address mode as there's no way for
   396  	   Nomad to know which is the best address to use for checks. Consul
   397  	   needs access to the address for any HTTP or TCP checks. Added in
   398  	   Nomad 0.7.1. Unlike `PortLabel`, this setting is *not* inherited
   399             from the `Service`.
   400  
   401  	 - `PortLabel`: Specifies the label of the port on which the check will
   402  	   be performed. Note this is the _label_ of the port and not the port
   403  	   number unless `AddressMode: "driver"`. The port label must match one
   404  	   defined in the Network stanza. If a port value was declared on the
   405  	   `Service`, this will inherit from that value if not supplied. If
   406  	   supplied, this value takes precedence over the `Service.PortLabel`
   407  	   value. This is useful for services which operate on multiple ports.
   408  	  `http` and `tcp` checks require a port while `script` checks do not.
   409  	  Checks will use the host IP and ports by default. In Nomad 0.7.1 or
   410  	  later numeric ports may be used if `AddressMode: "driver"` is set on
   411            the check.
   412  
   413  	 - `Header`: Headers for HTTP checks. Should be an object where the
   414  	   values are an array of values. Headers will be written once for each
   415             value.
   416  
   417           - `Interval`: This indicates the frequency of the health checks that
   418             Consul will perform.
   419  
   420           - `Timeout`: This indicates how long Consul will wait for a health
   421             check query to succeed.
   422  
   423           - `Method`: The HTTP method to use for HTTP checks. Defaults to GET.
   424  
   425           - `Path`: The path of the HTTP endpoint which Consul will query to query
   426             the health of a service if the type of the check is `http`. Nomad
   427             will add the IP of the service and the port, users are only required
   428             to add the relative URL of the health check endpoint. Absolute paths
   429             are not allowed.
   430  
   431           - `Protocol`: This indicates the protocol for the HTTP checks. Valid
   432             options are `http` and `https`. We default it to `http`.
   433  
   434           - `Command`: This is the command that the Nomad client runs for doing
   435             script based health check.
   436  
   437           - `Args`: Additional arguments to the `command` for script based health
   438             checks.
   439  
   440  	 - `TLSSkipVerify`: If true, Consul will not attempt to verify the
   441  	   certificate when performing HTTPS checks. Requires Consul >= 0.7.2.
   442  
   443  	   - `CheckRestart`: `CheckRestart` is an object which enables
   444  	     restarting of tasks based upon Consul health checks.
   445  
   446  	     - `Limit`: The number of unhealthy checks allowed before the
   447  	       service is restarted. Defaults to `0` which disables
   448                 health-based restarts.
   449  
   450  	     - `Grace`: The duration to wait after a task starts or restarts
   451  	       before counting unhealthy checks count against the limit.
   452                 Defaults to "1s".
   453  
   454  	     - `IgnoreWarnings`: Treat checks that are warning as passing.
   455  	       Defaults to false which means warnings are considered unhealthy.
   456  
   457  - `ShutdownDelay` - Specifies the duration to wait when killing a task between
   458    removing it from Consul and sending it a shutdown signal. Ideally services
   459    would fail healthchecks once they receive a shutdown signal. Alternatively
   460    `ShutdownDelay` may be set to give in flight requests time to complete before
   461    shutting down.
   462  
   463  - `Templates` - Specifies the set of [`Template`](#template) objects to render for the task.
   464    Templates can be used to inject both static and dynamic configuration with
   465    data populated from environment variables, Consul and Vault.
   466  
   467  - `User` - Set the user that will run the task. It defaults to the same user
   468    the Nomad client is being run as. This can only be set on Linux platforms.
   469  
   470  ### Resources
   471  
   472  The `Resources` object supports the following keys:
   473  
   474  - `CPU` - The CPU required in MHz.
   475  
   476  - `IOPS` - The number of IOPS required given as a weight between 10-1000.
   477  
   478  - `MemoryMB` - The memory required in MB.
   479  
   480  - `Networks` - A list of network objects.
   481  
   482  The Network object supports the following keys:
   483  
   484  - `MBits` - The number of MBits in bandwidth required.
   485  
   486  Nomad can allocate two types of ports to a task - Dynamic and Static/Reserved
   487  ports. A network object allows the user to specify a list of `DynamicPorts` and
   488  `ReservedPorts`. Each object supports the following attributes:
   489  
   490  - `Value` - The port number for static ports. If the port is dynamic, then this
   491    attribute is ignored.
   492  - `Label` - The label to annotate a port so that it can be referred in the
   493    service discovery block or environment variables.
   494  
   495  <a id="ephemeral_disk"></a>
   496  
   497  ### Ephemeral Disk
   498  
   499  The `EphemeralDisk` object supports the following keys:
   500  
   501  - `Migrate` - Specifies that the Nomad client should make a best-effort attempt
   502    to migrate the data from a remote machine if placement cannot be made on the
   503    original node. During data migration, the task will block starting until the
   504    data migration has completed. Value is a boolean and the default is false.
   505  
   506  - `SizeMB` - Specifies the size of the ephemeral disk in MB. Default is 300.
   507  
   508  - `Sticky` - Specifies that Nomad should make a best-effort attempt to place the
   509    updated allocation on the same machine. This will move the `local/` and
   510    `alloc/data` directories to the new allocation. Value is a boolean and the
   511    default is false.
   512  
   513  <a id="reschedule_policy"></a>
   514  
   515  ### Reschedule Policy
   516  
   517  The `ReschedulePolicy` object supports the following keys:
   518  
   519  - `Attempts` - `Attempts` is the number of reschedule attempts allowed
   520    in an `Interval`.
   521  
   522  - `Interval` - `Interval` is a time duration that is specified in nanoseconds.
   523    The `Interval` is a sliding window within which at most `Attempts` number
   524    of reschedule attempts are permitted.
   525  
   526  <a id="restart_policy"></a>
   527  
   528  ### Restart Policy
   529  
   530  The `RestartPolicy` object supports the following keys:
   531  
   532  - `Attempts` - `Attempts` is the number of restarts allowed in an `Interval`.
   533  
   534  - `Interval` - `Interval` is a time duration that is specified in nanoseconds.
   535    The `Interval` begins when the first task starts and ensures that only
   536    `Attempts` number of restarts happens within it. If more than `Attempts`
   537    number of failures happen, behavior is controlled by `Mode`.
   538  
   539  - `Delay` - A duration to wait before restarting a task. It is specified in
   540    nanoseconds. A random jitter of up to 25% is added to the delay.
   541  
   542  -   `Mode` - `Mode` is given as a string and controls the behavior when the task
   543      fails more than `Attempts` times in an `Interval`. Possible values are listed
   544      below:
   545  
   546      - `delay` - `delay` will delay the next restart until the next `Interval` is
   547        reached.
   548  
   549      - `fail` - `fail` will not restart the task again.
   550  
   551  ### Update
   552  
   553  Specifies the task group update strategy. When omitted, rolling updates are
   554  disabled. The update stanza can be specified at the job or task group level.
   555  When specified at the job, the update stanza is inherited by all task groups.
   556  When specified in both the job and in a task group, the stanzas are merged with
   557  the task group's taking precedence. The `Update` object supports the following
   558  attributes:
   559  
   560  - `MaxParallel` - `MaxParallel` is given as an integer value and specifies
   561  the number of tasks that can be updated at the same time.
   562  
   563  - `HealthCheck` - Specifies the mechanism in which allocations health is
   564  determined. The potential values are:
   565  
   566    - "checks" - Specifies that the allocation should be considered healthy when
   567      all of its tasks are running and their associated [checks][] are healthy,
   568      and unhealthy if any of the tasks fail or not all checks become healthy.
   569      This is a superset of "task_states" mode.
   570  
   571    - "task_states" - Specifies that the allocation should be considered healthy
   572      when all its tasks are running and unhealthy if tasks fail.
   573  
   574    - "manual" - Specifies that Nomad should not automatically determine health
   575      and that the operator will specify allocation health using the [HTTP
   576      API](/api/deployments.html#set-allocation-health-in-deployment).
   577  
   578  - `MinHealthyTime` - Specifies the minimum time the allocation must be in the
   579    healthy state before it is marked as healthy and unblocks further allocations
   580    from being updated. This is specified using a label suffix like "30s" or
   581    "15m".
   582  
   583  - `HealthyDeadline` - Specifies the deadline in which the allocation must be
   584    marked as healthy after which the allocation is automatically transitioned to
   585    unhealthy. This is specified using a label suffix like "2m" or "1h".
   586  
   587  - `AutoRevert` - Specifies if the job should auto-revert to the last stable job
   588    on deployment failure. A job is marked as stable if all the allocations as
   589    part of its deployment were marked healthy.
   590  
   591  - `Canary` - Specifies that changes to the job that would result in destructive
   592    updates should create the specified number of canaries without stopping any
   593    previous allocations. Once the operator determines the canaries are healthy,
   594    they can be promoted which unblocks a rolling update of the remaining
   595    allocations at a rate of `max_parallel`.
   596  
   597  - `Stagger` - Specifies the delay between migrating allocations off nodes marked
   598    for draining. This is specified using a label suffix like "30s" or "1h".
   599  
   600  An example `Update` block:
   601  
   602  ```json
   603  {
   604    "Update": {
   605          "MaxParallel": 3,
   606          "HealthCheck": "checks",
   607          "MinHealthyTime": 15000000000,
   608          "HealthyDeadline": 180000000000,
   609          "AutoRevert": false,
   610          "Canary": 1
   611    }
   612  }
   613  ```
   614  
   615  ### Constraint
   616  
   617  The `Constraint` object supports the following keys:
   618  
   619  - `LTarget` - Specifies the attribute to examine for the
   620    constraint. See the table of attributes [here](/docs/runtime/interpolation.html#interpreted_node_vars).
   621  
   622  - `RTarget` - Specifies the value to compare the attribute against.
   623    This can be a literal value, another attribute or a regular expression if
   624    the `Operator` is in "regexp" mode.
   625  
   626  - `Operand` - Specifies the test to be performed on the two targets. It takes on the
   627    following values:
   628  
   629    - `regexp` - Allows the `RTarget` to be a regular expression to be matched.
   630  
   631    - `set_contains` - Allows the `RTarget` to be a comma separated list of values
   632      that should be contained in the LTarget's value.
   633  
   634    - `distinct_hosts` - If set, the scheduler will not co-locate any task groups on the same
   635          machine. This can be specified as a job constraint which applies the
   636          constraint to all task groups in the job, or as a task group constraint which
   637          scopes the effect to just that group. The constraint may not be
   638          specified at the task level.
   639  
   640          Placing the constraint at both the job level and at the task group level is
   641          redundant since when placed at the job level, the constraint will be applied
   642          to all task groups. When specified, `LTarget` and `RTarget` should be
   643          omitted.
   644  
   645    - `distinct_property` - If set, the scheduler selects nodes that have a
   646          distinct value of the specified property. The `RTarget` specifies how
   647          many allocations are allowed to share the value of a property. The
   648          `RTarget` must be 1 or greater and if omitted, defaults to 1. This can
   649          be specified as a job constraint which applies the constraint to all
   650          task groups in the job, or as a task group constraint which scopes the
   651          effect to just that group. The constraint may not be specified at the
   652          task level.
   653  
   654          Placing the constraint at both the job level and at the task group level is
   655          redundant since when placed at the job level, the constraint will be applied
   656          to all task groups. When specified, `LTarget` should be the property
   657          that should be distinct and and `RTarget` should be omitted.
   658  
   659    - Comparison Operators - `=`, `==`, `is`, `!=`, `not`, `>`, `>=`, `<`, `<=`. The
   660      ordering is compared lexically.
   661  
   662  ### Log Rotation
   663  
   664  The `LogConfig` object configures the log rotation policy for a task's `stdout` and
   665  `stderr`. The `LogConfig` object supports the following attributes:
   666  
   667  - `MaxFiles` - The maximum number of rotated files Nomad will retain for
   668    `stdout` and `stderr`, each tracked individually.
   669  
   670  - `MaxFileSizeMB` - The size of each rotated file. The size is specified in
   671    `MB`.
   672  
   673  If the amount of disk resource requested for the task is less than the total
   674  amount of disk space needed to retain the rotated set of files, Nomad will return
   675  a validation error when a job is submitted.
   676  
   677  ```json
   678  {
   679    "LogConfig": {
   680      "MaxFiles": 3,
   681      "MaxFileSizeMB": 10
   682    }
   683  }
   684  ```
   685  
   686  In the above example we have asked Nomad to retain 3 rotated files for both
   687  `stderr` and `stdout` and size of each file is 10 MB. The minimum disk space that
   688  would be required for the task would be 60 MB.
   689  
   690  ### Artifact
   691  
   692  Nomad downloads artifacts using
   693  [`go-getter`](https://github.com/hashicorp/go-getter). The `go-getter` library
   694  allows downloading of artifacts from various sources using a URL as the input
   695  source. The key-value pairs given in the `options` block map directly to
   696  parameters appended to the supplied `source` URL. These are then used by
   697  `go-getter` to appropriately download the artifact. `go-getter` also has a CLI
   698  tool to validate its URL and can be used to check if the Nomad `artifact` is
   699  valid.
   700  
   701  Nomad allows downloading `http`, `https`, and `S3` artifacts. If these artifacts
   702  are archives (zip, tar.gz, bz2, etc.), these will be unarchived before the task
   703  is started.
   704  
   705  The `Artifact` object supports the following keys:
   706  
   707  - `GetterSource` - The path to the artifact to download.
   708  
   709  - `RelativeDest` - An optional path to download the artifact into relative to the
   710    root of the task's directory. If omitted, it will default to `local/`.
   711  
   712  - `GetterOptions` - A `map[string]string` block of options for `go-getter`.
   713    Full documentation of supported options are available
   714    [here](https://github.com/hashicorp/go-getter/tree/ef5edd3d8f6f482b775199be2f3734fd20e04d4a#protocol-specific-options-1).
   715    An example is given below:
   716  
   717  ```json
   718  {
   719    "GetterOptions": {
   720      "checksum": "md5:c4aa853ad2215426eb7d70a21922e794",
   721  
   722      "aws_access_key_id": "<id>",
   723      "aws_access_key_secret": "<secret>",
   724      "aws_access_token": "<token>"
   725    }
   726  }
   727  ```
   728  
   729  An example of downloading and unzipping an archive is as simple as:
   730  
   731  ```json
   732  {
   733    "Artifacts": [
   734      {
   735        "GetterSource": "https://example.com/my.zip",
   736        "GetterOptions": {
   737          "checksum": "md5:7f4b3e3b4dd5150d4e5aaaa5efada4c3"
   738        }
   739      }
   740    ]
   741  }
   742  ```
   743  
   744  #### S3 examples
   745  
   746  S3 has several different types of addressing and more detail can be found
   747  [here](http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro)
   748  
   749  S3 region specific endpoints can be found
   750  [here](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region)
   751  
   752  Path based style:
   753  
   754  ```json
   755  {
   756    "Artifacts": [
   757      {
   758        "GetterSource": "https://s3-us-west-2.amazonaws.com/my-bucket-example/my_app.tar.gz",
   759      }
   760    ]
   761  }
   762  ```
   763  
   764  or to override automatic detection in the URL, use the S3-specific syntax
   765  
   766  ```json
   767  {
   768    "Artifacts": [
   769      {
   770        "GetterSource": "s3::https://s3-eu-west-1.amazonaws.com/my-bucket-example/my_app.tar.gz",
   771      }
   772    ]
   773  }
   774  ```
   775  
   776  Virtual hosted based style
   777  
   778  ```json
   779  {
   780    "Artifacts": [
   781      {
   782        "GetterSource": "my-bucket-example.s3-eu-west-1.amazonaws.com/my_app.tar.gz",
   783      }
   784    ]
   785  }
   786  ```
   787  
   788  ### Template
   789  
   790  The `Template` block instantiates an instance of a template renderer. This
   791  creates a convenient way to ship configuration files that are populated from
   792  environment variables, Consul data, Vault secrets, or just general
   793  configurations within a Nomad task.
   794  
   795  Nomad utilizes a tool called [Consul Template][ct]. Since Nomad v0.5.3, the
   796  template can reference [Nomad's runtime environment variables][env]. For a full
   797  list of the API template functions, please refer to the [Consul Template
   798  README][ct].
   799  
   800  
   801  `Template` object supports following attributes:
   802  
   803  - `ChangeMode` - Specifies the behavior Nomad should take if the rendered
   804    template changes. The default value is `"restart"`. The possible values are:
   805  
   806    - `"noop"` - take no action (continue running the task)
   807    - `"restart"` - restart the task
   808    - `"signal"` - send a configurable signal to the task
   809  
   810  - `ChangeSignal` - Specifies the signal to send to the task as a string like
   811    "SIGUSR1" or "SIGINT". This option is required if the `ChangeMode` is
   812    `signal`.
   813  
   814  - `DestPath` - Specifies the location where the resulting template should be
   815    rendered, relative to the task directory.
   816  
   817  - `EmbeddedTmpl` -  Specifies the raw template to execute. One of `SourcePath`
   818    or `EmbeddedTmpl` must be specified, but not both. This is useful for smaller
   819    templates, but we recommend using `SourcePath` for larger templates.
   820  
   821  - `Envvars` - Specifies the template should be read back as environment
   822    variables for the task.
   823  
   824  - `LeftDelim` - Specifies the left delimiter to use in the template. The default
   825    is "{{" for some templates, it may be easier to use a different delimiter that
   826    does not conflict with the output file itself.
   827  
   828  - `Perms` - Specifies the rendered template's permissions. File permissions are
   829    given as octal of the Unix file permissions rwxrwxrwx.
   830  
   831  - `RightDelim` - Specifies the right delimiter to use in the template. The default
   832    is "}}" for some templates, it may be easier to use a different delimiter that
   833    does not conflict with the output file itself.
   834  
   835  - `SourcePath` - Specifies the path to the template to be rendered. `SourcePath`
   836    is mutually exclusive with `EmbeddedTmpl` attribute. The source can be fetched
   837    using an [`Artifact`](#artifact) resource. The template must exist on the
   838    machine prior to starting the task; it is not possible to reference a template
   839    inside of a Docker container, for example.
   840  
   841  - `Splay` - Specifies a random amount of time to wait between 0 ms and the given
   842    splay value before invoking the change mode. Should be specified in
   843    nanoseconds.
   844  
   845  - `VaultGrace` - Specifies the grace period between lease renewal and secret
   846    re-acquisition. When renewing a secret, if the remaining lease is less than or
   847    equal to the configured grace, the template will request a new credential.
   848    This prevents Vault from revoking the secret at its expiration and the task
   849    having a stale secret. If the grace is set to a value that is higher than your
   850    default TTL or max TTL, the template will always read a new secret. If the
   851    task defines several templates, the `vault_grace` will be set to the lowest
   852    value across all the templates.
   853  
   854  ```json
   855  {
   856    "Templates": [
   857      {
   858        "SourcePath": "local/config.conf.tpl",
   859        "DestPath": "local/config.conf",
   860        "EmbeddedTmpl": "",
   861        "ChangeMode": "signal",
   862        "ChangeSignal": "SIGUSR1",
   863        "Splay": 5000000000
   864      }
   865    ]
   866  }
   867  ```
   868  
   869  [ct]: https://github.com/hashicorp/consul-template "Consul Template by HashiCorp"
   870  [env]: /docs/runtime/environment.html "Nomad Runtime Environment"