Merge pull request #1534 from influxdata/export-resources

Add how export resources by name
pull/1539/head
kelseiv 2020-09-23 08:57:30 -07:00 committed by GitHub
commit ac49b569da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 90 additions and 30 deletions

View File

@ -51,6 +51,7 @@ In **InfluxDB Cloud**, your user account is an organization.
4. Export the template _(see [below](#export-a-template))_. 4. Export the template _(see [below](#export-a-template))_.
## Export a template ## Export a template
Do one of the following to export a template: Do one of the following to export a template:
- [Export all resources in an organization](#export-all-resources) - [Export all resources in an organization](#export-all-resources)
@ -58,6 +59,7 @@ Do one of the following to export a template:
- [Export a stack and its associated resources](#export-a-stack) - [Export a stack and its associated resources](#export-a-stack)
### Export all resources ### Export all resources
To export all templatable resources within an organization to a template manifest, To export all templatable resources within an organization to a template manifest,
use the `influx export all` command. use the `influx export all` command.
Provide the following: Provide the following:
@ -69,6 +71,7 @@ Provide the following:
**JSON** (`.json`) are supported. **JSON** (`.json`) are supported.
###### Export all resources to a template ###### Export all resources to a template
```sh ```sh
# Syntax # Syntax
influx export all -o <org-name> -f <file-path> -t <token> influx export all -o <org-name> -f <file-path> -t <token>
@ -81,11 +84,13 @@ influx export all \
``` ```
#### Export resources filtered by labelName or resourceKind #### Export resources filtered by labelName or resourceKind
The `influx export all` command has an optional `--filter` flag that exports The `influx export all` command has an optional `--filter` flag that exports
only resources that match specified label names or resource kinds. only resources that match specified label names or resource kinds.
Provide multiple filters for both `labelName` and `resourceKind` Provide multiple filters for both `labelName` and `resourceKind`.
###### Export only dashboards and buckets with specific labels ###### Export only dashboards and buckets with specific labels
The following example exports resources that match this predicate logic: The following example exports resources that match this predicate logic:
```js ```js
@ -109,8 +114,8 @@ For information about flags, see the
[`influx export all` documentation](/influxdb/v2.0/reference/cli/influx/export/all/). [`influx export all` documentation](/influxdb/v2.0/reference/cli/influx/export/all/).
### Export specific resources ### Export specific resources
To export specific resources within an organization to a template manifest,
use the `influx export` with resource flags for each resource to include. To export specific resources within an organization to a template manifest, use the `influx export` with resource flags for each resource to include.
Provide the following: Provide the following:
- **Organization name** or **ID** - **Organization name** or **ID**
@ -118,16 +123,17 @@ Provide the following:
- **Destination path and filename** for the template manifest. - **Destination path and filename** for the template manifest.
The filename extension determines the template format—both **YAML** (`.yml`) and The filename extension determines the template format—both **YAML** (`.yml`) and
**JSON** (`.json`) are supported. **JSON** (`.json`) are supported.
- **Resource flags** with corresponding lists of resource IDs to include in the template. - **Resource flags** with corresponding lists of resource IDs or resource names to include in the template.
For information about what resource flags are available, see the For information about what resource flags are available, see the
[`influx export` documentation](/influxdb/v2.0/reference/cli/influx/export/). [`influx export` documentation](/influxdb/v2.0/reference/cli/influx/export/).
###### Export specific resources to a template ###### Export specific resources to a template
```sh ```sh
# Syntax # Syntax
influx export all -o <org-name> -f <file-path> -t <token> [resource-flags] influx export all -o <org-name> -f <file-path> -t <token> [resource-flags]
# Example # Export specific resources by ID
influx export all \ influx export all \
-o my-org \ -o my-org \
-f ~/templates/awesome-template.yml \ -f ~/templates/awesome-template.yml \
@ -135,9 +141,19 @@ influx export all \
--buckets=00x000ooo0xx0xx,o0xx0xx00x000oo \ --buckets=00x000ooo0xx0xx,o0xx0xx00x000oo \
--dashboards=00000xX0x0X00x000 \ --dashboards=00000xX0x0X00x000 \
--telegraf-configs=00000x0x000X0x0X0 --telegraf-configs=00000x0x000X0x0X0
# Export specific resources by name
influx export all \
-o my-org \
-f ~/templates/awesome-template.yml \
-t $INFLUX_TOKEN \
--bucket-names=bucket1,bucket2 \
--dashboard-names=dashboard1,dashboard2 \
--telegraf-config-names=telegrafconfig1,telegrafconfig2
``` ```
### Export a stack ### Export a stack
To export a stack and all its associated resources as a template, use the To export a stack and all its associated resources as a template, use the
`influx export stack` command. `influx export stack` command.
Provide the following: Provide the following:
@ -150,6 +166,7 @@ Provide the following:
- **Stack ID** - **Stack ID**
###### Export a stack as a template ###### Export a stack as a template
```sh ```sh
# Syntax # Syntax
influx export stack \ influx export stack \
@ -167,6 +184,7 @@ influx export stack \
``` ```
## Include user-definable resource names ## Include user-definable resource names
After exporting a template manifest, replace resource names with **environment references** After exporting a template manifest, replace resource names with **environment references**
to let users customize resource names when installing your template. to let users customize resource names when installing your template.
@ -178,7 +196,7 @@ to let users customize resource names when installing your template.
- `endpointName` _(unique to `NotificationRule` resources)_ - `endpointName` _(unique to `NotificationRule` resources)_
3. Replace the resource field value with an `envRef` object with a `key` property 3. Replace the resource field value with an `envRef` object with a `key` property
that reference the key of a key-value pair the user provides when installing the template. that references the key of a key-value pair the user provides when installing the template.
During installation, the `envRef` object is replaced by the value of the During installation, the `envRef` object is replaced by the value of the
referenced key-value pair. referenced key-value pair.
If the user does not provide the environment reference key-value pair, InfluxDB If the user does not provide the environment reference key-value pair, InfluxDB
@ -233,6 +251,7 @@ exist in the template and what keys to use to replace them._
{{% note %}} {{% note %}}
#### Resource fields that support environment references #### Resource fields that support environment references
Only the following fields support environment references: Only the following fields support environment references:
- `metadata.name` - `metadata.name`
@ -241,6 +260,7 @@ Only the following fields support environment references:
{{% /note %}} {{% /note %}}
## Share your InfluxDB templates ## Share your InfluxDB templates
Share your InfluxDB templates with the entire InfluxData community. Share your InfluxDB templates with the entire InfluxData community.
**Contribute your template to the [InfluxDB Community Templates](https://github.com/influxdata/community-templates/) **Contribute your template to the [InfluxDB Community Templates](https://github.com/influxdata/community-templates/)
repository on GitHub.** repository on GitHub.**

View File

@ -67,6 +67,7 @@ influx [command]
| [template](/influxdb/v2.0/reference/cli/influx/template) | Summarize and validate an InfluxDB template | | [template](/influxdb/v2.0/reference/cli/influx/template) | Summarize and validate an InfluxDB template |
| [transpile](/influxdb/v2.0/reference/cli/influx/transpile) | Manually transpile an InfluxQL query to Flux | | [transpile](/influxdb/v2.0/reference/cli/influx/transpile) | Manually transpile an InfluxQL query to Flux |
| [user](/influxdb/v2.0/reference/cli/influx/user) | User management commands | | [user](/influxdb/v2.0/reference/cli/influx/user) | User management commands |
| [version](/influxdb/v2.0/reference/cli/influx/version) | Print the influx CLI version |
| [write](/influxdb/v2.0/reference/cli/influx/write) | Write points to InfluxDB | | [write](/influxdb/v2.0/reference/cli/influx/write) | Write points to InfluxDB |
## Mapped environment variables ## Mapped environment variables

View File

@ -16,12 +16,14 @@ _For detailed examples of exporting InfluxDB templates, see
[Create an InfluxDB template](/influxdb/v2.0/influxdb-templates/create/)._ [Create an InfluxDB template](/influxdb/v2.0/influxdb-templates/create/)._
## Usage ## Usage
``` ```
influx export [flags] influx export [flags]
influx export [command] influx export [command]
``` ```
## Available subcommands ## Available subcommands
| Subcommand | Description | | Subcommand | Description |
|:---------- |:----------- | |:---------- |:----------- |
| [all](/influxdb/v2.0/reference/cli/influx/export/all/) | Export all resources in an organization as a template | | [all](/influxdb/v2.0/reference/cli/influx/export/all/) | Export all resources in an organization as a template |
@ -29,26 +31,34 @@ influx export [command]
## Flags ## Flags
| Flag | | Description | Input Type | {{< cli/mapped >}} | | Flag | | Description | Input Type | {{< cli/mapped >}} |
|:---- |:--- |:----------- |:---------- |:------------------ | |:---- |:--- |:----------- |:---------- |:------------------ |
| `-c` | `--active-config` | CLI configuration to use for command | string | | | | `--buckets` | Comma-separated list of bucket IDs | string | |
| | `--buckets` | Comma-separated list of bucket IDs | string | | | | `--bucket-names` | Comma-separated list of bucket names | string | |
| | `--checks` | Comma-separated list of check IDs | string | | | | `--checks` | Comma-separated list of check IDs | string | |
| | `--configs-path` | Path to `influx` CLI configurations (default `~/.influxdbv2/configs`) | string |`INFLUX_CONFIGS_PATH` | | | `--check-names` | Comma-separated list of check names | string | |
| | `--dashboards` | Comma-separated list of dashboard IDs | string | | | | `--configs-path` | Path to `influx` CLI configurations (default `~/.influxdbv2/configs`) | string |`INFLUX_CONFIGS_PATH` |
| | `--endpoints` | Comma-separated list of notification endpoint IDs | string | | | | `--dashboards` | Comma-separated list of dashboard IDs | string | |
| `-f` | `--file` | Template output file. Defaults to stdout. Use `.yml` or `.json` file extensions. | string | | | | `--dashboard-names` | Comma-separated list of dashboard names | string | |
| `-h` | `--help` | Help for the `export` command | | | | | `--endpoints` | Comma-separated list of notification endpoint IDs | string | |
| | `--host` | HTTP address of InfluxDB (default `http://localhost:8086`) | string | `INFLUX_HOST` | | | `--endpoint-names` | Comma-separated list of notification endpoint names | string | |
| | `--labels` | Comma-separated list of label IDs | string | | | `-f` | `--file` | Template output file. Defaults to stdout. Use `.yml` or `.json` file extensions. | string | |
| | `--resource-type` | Resource type associated with all IDs via stdin | string | | | `-h` | `--help` | Help for the `export` command | | |
| | `--rules` | Comma-separated list of notification rule IDs | string | | | | `--host` | HTTP address of InfluxDB (default `http://localhost:9999`) | string | `INFLUX_HOST` |
| | `--skip-verify` | Skip TLS certificate verification | | | | | `--labels` | Comma-separated list of label IDs | string | |
| | `--stack-id` | Stack ID to include resources from in export | string | | | | `--label-names` | Comma-separated list of label names | string | |
| | `--tasks` | Comma-separated list of task IDs | string | | | | `--resource-type` | Resource type associated with all IDs via stdin | string | |
| | `--telegraf-configs` | Comma-separated list of Telegraf configuration IDs | string | | | | `--rules` | Comma-separated list of notification rule IDs | string | |
| `-t` | `--token` | Authentication token | string | `INFLUX_TOKEN` | | | `--rule-names` | Comma-separated list of notification rule names | string | |
| | `--variables` | Comma-separated list of variable IDs | string | | | | `--skip-verify` | Skip TLS certificate verification | | |
| | `--stack-id` | Stack ID to include resources from in export | string | |
| | `--tasks` | Comma-separated list of task IDs | string | |
| | `--task-names` | Comma-separated list of task names | string | |
| | `--telegraf-configs` | Comma-separated list of Telegraf configuration IDs | string | |
| | `--telegraf-config-names` | Comma-separated list of Telegraf configuration names | string | |
| `-t` | `--token` | Authentication token | string | `INFLUX_TOKEN` |
| | `--variables` | Comma-separated list of variable IDs | string | |
| | `--variable-names` | Comma-separated list of variable names | string | |
## Examples ## Examples
```sh ```sh
@ -61,10 +71,16 @@ influx export \
--labels=$LID1,$LID2,$LID3 \ --labels=$LID1,$LID2,$LID3 \
--dashboards=$DID1,$DID2,$DID3 --dashboards=$DID1,$DID2,$DID3
# Export buckets, labels, and dashboards by name
influx export \
--buckets=bucket1,bucket2,bucket3 \
--labels=label1,label2,label3 \
--dashboards=dashboard1,dashboard2,dashboard3
# Export all resources associated with a stack # Export all resources associated with a stack
influx export --stack-id $STACK_ID influx export --stack-id $STACK_ID
# Export resources associated with a stack and resources # Export resources associated with a stack and resources
# *not* associated with the stack # *not* associated with the stack
influx export --stack-id $STACK_ID --buckets $BUCKET_ID influx export --stack-id $STACK_ID --buckets $BUCKET_ID --dashboard-names bucket1
``` ```

View File

@ -0,0 +1,23 @@
---
title: influx version
description: The `influx version` command outputs the current version of the influx command line interface (CLI).
influxdb/v2.0/tags: [influx, cli]
menu:
influxdb_2_0_ref:
parent: influx
weight: 202
---
The `influx version` command outputs the current version of the influx command line interface (CLI).
## Usage
```
influx version [flags]
```
## Flags
| Flag | | Description |
|:---- |:--- |:----------- |
| `-h` | `--help` | Help for the `version` command |

View File

@ -56,7 +56,7 @@ We are going to write some data in [line protocol](/influxdb/v2.0/reference/synt
3. Instantiate the client. The `InfluxDBClient` object takes three named parameters: `url`, `org`, and `token`. Pass in the named parameters. 3. Instantiate the client. The `InfluxDBClient` object takes three named parameters: `url`, `org`, and `token`. Pass in the named parameters.
```python ```python
client = InfluxDBClient( client = influxdb_client.InfluxDBClient(
url=url, url=url,
token=token, token=token,
org=org org=org

View File

@ -1,5 +1,5 @@
--- ---
title: InfluxDB API title: Use InfluxDB API
seotitle: Write data with the InfluxDB API seotitle: Write data with the InfluxDB API
list_title: Write data with the InfluxDB API list_title: Write data with the InfluxDB API
weight: 206 weight: 206

View File

@ -1,5 +1,5 @@
--- ---
title: Influx CLI title: Use influx CLI
seotitle: Write data with the influx CLI seotitle: Write data with the influx CLI
list_title: Write data with the influx CLI list_title: Write data with the influx CLI
weight: 205 weight: 205