content/shared/influxdb-v2/tools/influxdb-templates/use.md
Use the influx command line interface (CLI) to summarize, validate, and apply
templates from your local filesystem and from URLs.
The InfluxDB community templates repository is home to a growing number of InfluxDB templates developed and maintained by others in the InfluxData community. Apply community templates directly from GitHub using a template's download URL or download the template.
{{< youtube 2JjW4Rym9XE >}}
[!Note] The community templates are under the following root URL:
texthttps://raw.githubusercontent.com/influxdata/community-templates/master/For example, to access the Docker community template, use the following URL:
texthttps://raw.githubusercontent.com/influxdata/community-templates/master/docker/docker.yml
<a class="btn" href="https://github.com/influxdata/community-templates/" target="\_blank">View InfluxDB Community Templates</a>
To view a summary of what's included in a template before applying the template,
use the influx template command.
View a summary of a template stored in your local filesystem or from a URL.
{{< code-tabs-wrapper >}} {{% code-tabs %}} From a file From a URL {{% /code-tabs %}} {{% code-tab-content %}}
# Syntax
influx template -f <FILE_PATH>
# Example
influx template -org ORG_NAME -f /path/to/templates/TEMPLATE_FILE.yml
{{% /code-tab-content %}} {{% code-tab-content %}}
# Syntax
influx template -org <ORG_NAME> -u <FILE_URL>
# Example
influx template -u https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
To validate a template before you install it or troubleshoot a template, use
the influx template validate command.
Validate a template stored in your local filesystem or from a URL.
{{< code-tabs-wrapper >}} {{% code-tabs %}} From a file From a URL {{% /code-tabs %}} {{% code-tab-content %}}
# Syntax
influx template validate -org <ORG_NAME> -f <FILE_PATH>
# Example
influx template validate -org ORG_NAME -f /path/to/templates/TEMPLATE_FILE.yml
{{% /code-tab-content %}} {{% code-tab-content %}}
# Syntax
influx template validate -u <FILE_URL>
# Example
influx template validate -u https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
Use the influx apply command to install templates
from your local filesystem or from URLs.
The default output is a summary of the template in "pretty" format and a prompt
to confirm applying the changes.
# Syntax
influx apply \
-o <INFLUX_ORG> \
-f <FILE_PATH> \
-u <URL> \
--secret=<SECRET_KEY>=<SECRET_VALUE>
[!Note]
Apply templates to an existing stack
To apply a template to an existing stack, include the stack ID when applying the template. Any time you apply a template without a stack ID, InfluxDB initializes a new stack and all new resources. For more information, see InfluxDB stacks.
You can extract a stack ID from the output of
<!--pytest.mark.skip-->influx stacksand pass it toinflux apply:bash# Extract stack ID by name and apply a template to that stack influx stacks | grep STACK_NAME | awk '{print $1}' | xargs -I{} influx apply -o ORG_NAME -f /path/to/TEMPLATE_FILE.yml --stack-id {}
To install templates stored on your local machine, use the -f or --file flag
to provide the file path of the template manifest.
# Example
# Apply multiple templates
influx apply -o ORG_NAME \
-f /path/to/templates/TEMPLATE_FILE_1.yml \
-f /path/to/templates/TEMPLATE_FILE_2.yml
To skip the confirmation and apply the templates non-interactively, pass --force yes:
# Download templates for tests
curl https://raw.githubusercontent.com/influxdata/community-templates/master/docker/docker.yml \
-so /path/to/templates/TEMPLATE_FILE_1.yml &&
curl https://raw.githubusercontent.com/influxdata/community-templates/master/github/github.yml \
-so /path/to/templates/TEMPLATE_FILE_2.yml &&
influx apply -o ORG_NAME \
-f /path/to/templates/TEMPLATE_FILE_1.yml \
-f /path/to/templates/TEMPLATE_FILE_2.yml \
--force yes
To apply all templates in a directory, use the -f or --file flag to provide
the directory path of the directory where template manifests are stored.
By default, this only applies templates stored in the specified directory.
To apply all templates stored in the specified directory and its subdirectories,
include the -R, --recurse flag.
# Examples
# Apply all templates in a directory
influx apply -o ORG_NAME -f /path/to/templates/
# Apply all templates in a directory and its subdirectories
influx apply -o ORG_NAME -f /path/to/templates/ --recurse
To apply templates from a URL, use the -u or --template-url flag to provide the URL
of the template manifest.
# Example
# Apply multiple templates from URLs
influx apply -o ORG_NAME \
-u https://raw.githubusercontent.com/influxdata/community-templates/master/docker/docker.yml \
-u https://raw.githubusercontent.com/influxdata/community-templates/master/github/github.yml
To apply templates from files and URLs in a single command, include multiple
file or directory paths and URLs, each with the appropriate -f or -u flag.
# Example
influx apply -o ORG_NAME \
-u https://raw.githubusercontent.com/influxdata/community-templates/master/raspberry-pi/raspberry-pi-system.yml \
-u https://raw.githubusercontent.com/influxdata/community-templates/master/minio/minio.yml \
-f /path/to/templates/TEMPLATE_FILE_1.yml \
-f /path/to/templates/TEMPLATE_FILE_2.yml \
--recurse
{{% show-in "v2" %}}
Some templates include environment references that let you provide custom resource names.
The influx apply command prompts you to provide a value for each environment
reference in the template.
You can also provide values for environment references by including an --env-ref
flag with a key-value pair comprised of the environment reference key and the
value to replace it.
# Example
influx apply -o ORG_NAME -f /path/to/templates/TEMPLATE_FILE.yml \
--env-ref=bucket-name-1=myBucket \
--env-ref=label-name-1=Label1 \
--env-ref=label-name-2=Label2
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
[!Warning]
Environment reference substitution not supported
This feature is not supported by InfluxDB Cloud.
{{% /show-in %}}
Some templates use secrets in queries.
Secret values are not included in templates.
To define secret values when installing a template, include the --secret flag
with the secret key-value pair.
# Examples
# Define a single secret when applying a template
influx apply -o ORG_NAME -f /path/to/templates/TEMPLATE_FILE.yml \
--secret=FOO=BAR
# Define multiple secrets when applying a template
influx apply -o ORG_NAME -f /path/to/templates/TEMPLATE_FILE.yml \
--secret=FOO=bar \
--secret=BAZ=quz
To add a secret after applying a template, see Add secrets.