added new variable types, resolves #168

pull/190/head
Scott Anderson 2019-04-26 15:59:33 -06:00
parent 2ffd8bc1a7
commit 1de996bd25
1 changed files with 42 additions and 8 deletions

View File

@ -9,26 +9,43 @@ weight: 207
"v2.0/tags": [variables]
---
{{% note %}}
In the current version of InfluxDB v2.0 alpha, only [query-populated variables](#query) are available.
{{% /note %}}
Variable types determine how a variable's list of possible values is populated.
The following variable types are available:
- [Map](#map)
- [Query](#query)
- [CSV](#csv)
## Map
Map variables use a list of key value pairs in CSV format to map keys to specific values.
Keys populate the variable's value list in the InfluxDB user interface (UI), but
values are used when actually processing the query.
The most common use case for map variables is aliasing simple, human-readable keys
to complex values.
##### Map variable CSV example
```js
Juanito MacNeil,"5TKl6l8i4idg15Fxxe4P"
Astrophel Chaudhary,"bDhZbuVj5RV94NcFXZPm"
Ochieng Benes,"YIhg6SoMKRUH8FMlHs3V"
Mila Emile,"o61AhpOGr5aO3cYVArC0"
```
## Query
Variable values are populated using the `_value` column of a Flux query.
Query variable values are populated using the `_value` column of a Flux query.
##### Variable query example
##### Query variable example
```js
// List all buckets
buckets()
|> rename(columns: {"name": "_value"})
|> rename(columns: {"name": "_value"})
|> keep(columns: ["_value"])
```
_For examples of dashboard variable queries, see [Common variable queries](/v2.0/visualize-data/variables/common-variables)._
{{% note %}}
#### Important things to note about variable queries
- The variable will only use values from the `_value` column.
If the data youre looking for is in a column other than `_value`, use the
@ -39,3 +56,20 @@ _For examples of dashboard variable queries, see [Common variable queries](/v2.0
Use the [`group()` function](/v2.0/reference/flux/functions/built-in/transformations/group)
to group everything into a single table.
- Do not use any [predefined dashboard variables](/v2.0/visualize-data/variables/#predefined-dashboard-variables) in variable queries.
{{% /note %}}
## CSV
CSV variables use a CSV-formatted list to populate variable values.
A common use case is when the list of potential values is static and cannot be
queried from InfluxDB.
##### CSV variable examples
```
value1, value2, value3, value4
```
```
value1
value2
value3
value4
```