Use InfluxDB templates

Use the influx command line interface (CLI) to summarize, validate, and apply templates from your local filesystem and from URLs.

Use InfluxDB community templates

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.

When attempting to access the community templates via the URL, the templates use the following as the root of the URL:

  1. https://raw.githubusercontent.com/influxdata/community-templates/master/

For example, the Docker community template can be accessed via:

  1. https://raw.githubusercontent.com/influxdata/community-templates/master/docker/docker.yml

View InfluxDB Community Templates

View a template summary

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.

From a file From a URL

  1. # Syntax
  2. influx template -f <template-file-path>
  3. # Example
  4. influx template -f /path/to/template.yml
  1. # Syntax
  2. influx template -u <template-url>
  3. # Example
  4. influx template -u https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml

Validate a template

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.

From a file From a URL

  1. # Syntax
  2. influx template validate -f <template-file-path>
  3. # Example
  4. influx template validate -f /path/to/template.yml
  1. # Syntax
  2. influx template validate -u <template-url>
  3. # Example
  4. influx template validate -u https://raw.githubusercontent.com/influxdata/community-templates/master/linux_system/linux_system.yml

Apply templates

Use the influx apply command to install templates from your local filesystem or from URLs.

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.

Apply a template from a file

To install templates stored on your local machine, use the -f or --file flag to provide the file path of the template manifest.

  1. # Syntax
  2. influx apply -o <org-name> -f <template-file-path>
  3. # Examples
  4. # Apply a single template
  5. influx apply -o example-org -f /path/to/template.yml
  6. # Apply multiple templates
  7. influx apply -o example-org \
  8. -f /path/to/this/template.yml \
  9. -f /path/to/that/template.yml

Apply all templates in a directory

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.

  1. # Syntax
  2. influx apply -o <org-name> -f <template-directory-path>
  3. # Examples
  4. # Apply all templates in a directory
  5. influx apply -o example-org -f /path/to/template/dir/
  6. # Apply all templates in a directory and its subdirectories
  7. influx apply -o example-org -f /path/to/template/dir/ -R

Apply a template from a URL

To apply templates from a URL, use the -u or --template-url flag to provide the URL of the template manifest.

  1. # Syntax
  2. influx apply -o <org-name> -u <template-url>
  3. # Examples
  4. # Apply a single template from a URL
  5. influx apply -o example-org -u https://example.com/templates/template.yml
  6. # Apply multiple templates from URLs
  7. influx apply -o example-org \
  8. -u https://example.com/templates/template1.yml \
  9. -u https://example.com/templates/template2.yml

Apply templates from both files and URLs

To apply templates from both files and URLs in a single command, include multiple file or directory paths and URLs, each with the appropriate -f or -u flag.

  1. # Syntax
  2. influx apply -o <org-name> -u <template-url> -f <template-path>
  3. # Example
  4. influx apply -o example-org \
  5. -u https://example.com/templates/template1.yml \
  6. -u https://example.com/templates/template2.yml \
  7. -f ~/templates/custom-template.yml \
  8. -f ~/templates/iot/home/ \
  9. --recurse

Define environment references

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.

  1. influx apply -o example-org -f /path/to/template.yml \
  2. --env-ref=bucket-name-1=myBucket
  3. --env-ref=label-name-1=Label1 \
  4. --env-ref=label-name-2=Label2

Include a secret when installing a template

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.

  1. # Syntax
  2. influx apply -o <org-name> -f <template-file-path> \
  3. --secret=<secret-key>=<secret-value>
  4. # Examples
  5. # Define a single secret when applying a template
  6. influx apply -o example-org -f /path/to/template.yml \
  7. --secret=FOO=BAR
  8. # Define multiple secrets when applying a template
  9. influx apply -o example-org -f /path/to/template.yml \
  10. --secret=FOO=bar \
  11. --secret=BAZ=quz

To add a secret after applying a template, see Add secrets.

Related articles

templates