---
layout: "docs"
page_title: "Interpreted Variables"
sidebar_current: "docs-jobspec-interpreted"
description: |-
Learn about the Nomad's interpreted variables.
---
# Interpreted Variables
Nomad support interpreting two classes of variables, node attributes and runtime
environment variables. Node attributes are interpretable in constraints, task
environment variables and certain driver fields. Runtime environment variables
are not interpretable in constraints because they are only defined once the
scheduler has placed them on a particular node.
The syntax for interpreting variables is `${variable}`. An example and a
comprehensive list of interpretable fields can be seen below:
```
task "demo" {
driver = "docker"
# Drivers support interpreting node attributes and runtime environment
# variables
config {
image = "my-app"
# Interpret runtime variables to inject the address to bind to and the
# location to write logs to.
args = ["--bind=${NOMAD_ADDR_RPC}", "--logs=${NOMAD_ALLOC_DIR}/logs"]
port_map {
RPC = 6379
}
}
# Constraints only support node attributes as runtime environment variables
# are only defined after the task is placed on a node.
constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}
# Environment variables are interpreted and can contain both runtime and
# node attributes.
env {
"DC" = "Running on datacenter ${node.datacenter}"
"VERSION" = "Version ${NOMAD_META_VERSION}"
}
# Meta keys are also interpretable.
meta {
VERSION = "v0.3"
}
}
```
## Node Variables
Below is a full listing of node attributes that are interpretable. These
attributes are Interpreted by __both__ constraints and within the task and
driver.
Attribute |
Description |
arch |
CPU architecture of the client. Examples: `amd64`, `386` |
consul.datacenter |
The Consul datacenter of the client node if Consul found |
cpu.numcores |
Number of CPU cores on the client |
driver."key" |
See the [task drivers](/docs/drivers/index.html) for attribute documentation |
hostname |
Hostname of the client |
kernel.name |
Kernel of the client. Examples: `linux`, `darwin` |
kernel.version |
Version of the client kernel. Examples: `3.19.0-25-generic`, `15.0.0` |
platform.aws.ami-id |
On EC2, the AMI ID of the client node |
platform.aws.instance-type |
On EC2, the instance type of the client node |
os.name |
Operating system of the client. Examples: `ubuntu`, `windows`, `darwin` |
os.version |
Version of the client OS |
## Environment Variables
Variable |
Description |
${NOMAD_ALLOC_DIR} |
The path to the shared `alloc/` directory. See
[here](/docs/jobspec/environment.html#task_dir) for more
information. |
${NOMAD_TASK_DIR} |
The path to the task `local/` directory. See
[here](/docs/jobspec/environment.html#task_dir) for more
information. |
${NOMAD_MEMORY_LIMIT} |
The memory limit in MBits for the task |
${NOMAD_CPU_LIMIT} |
The CPU limit in MHz for the task |
${NOMAD_ALLOC_ID} |
The allocation ID of the task |
${NOMAD_ALLOC_NAME} |
The allocation name of the task |
${NOMAD_ALLOC_INDEX} |
The allocation index; useful to distinguish instances of task groups |
${NOMAD_TASK_NAME} |
The task's name |
${NOMAD_IP_"label"} |
The IP for the given port `label`. See
[here](/docs/jobspec/networking.html) for more information. |
${NOMAD_PORT_"label"} |
The port for the port `label`. See [here](/docs/jobspec/networking.html)
for more information. |
${NOMAD_ADDR_"label"} |
The `ip:port` pair for the given port `label`. See
[here](/docs/jobspec/networking.html) for more information. |
${NOMAD_HOST_PORT_"label"} |
The port on the host if port forwarding is being used for the port
`label`. See [here](/docs/jobspec/networking.html#mapped_ports) for more
information. |
${NOMAD_META_"key"} |
The metadata value given by `key` on the task's metadata |
${"env_key"} |
Interpret an environment variable with key `env_key` set on the task. |