updates to variable docs

pull/113/head
Scott Anderson 2019-03-28 17:32:26 -06:00
parent 643f4b69bf
commit b30e8c1448
6 changed files with 44 additions and 20 deletions

View File

@ -28,12 +28,12 @@ from(bucket: v.bucket)
|> aggregateWindow(every: v.windowPeriod, fn: mean)
```
## Manage custom variables
As you build queries, In the Cell Editor and Data explorer, available variables are listed in the variables tab.
Must use the script builder. Click on a variable to input into your script.
Hover over the variable in the variables tab to select a value for the current query.
When building Flux queries for dashboard cells, view available dashboard variables
in the **Variables** tab next to the Functions tab.
{{< children >}}
{{< img-hd src="/img/2-0-variables-data-explorer-view.png" />}}
Click on a variable name to add it to your query and select a value from the **Value** dropdown.
## Predefined dashboard variables
The InfluxDB provides the following predefined dashboard variables:
@ -61,3 +61,8 @@ in data aggregation operations.
The value of this variable is calculated by dividing the total time within the displayed
time range by the dashboard refresh interval (defined by the **Refresh** dropdown).
## Custom dashboard variables
Create, manage, and use custom dashboard variables in the InfluxDB user interface (UI).
{{< children >}}

View File

@ -4,35 +4,43 @@ description: Useful queries to use to populate values in common dashboard variab
menu:
v2_0:
parent: Use and manage variables
name: Common Variables
weight: 206
name: Common variable queries
weight: 208
"v2.0/tags": [variables]
---
##### List buckets
### List buckets
List all buckets in the current organization.
```js
buckets()
|> rename(columns: {"name": "_value"})
|> keep(columns: ["_value"])
```
##### List measurements
### List measurements
List all measurements in a specified bucket.
```js
import "influxdata/influxdb/v1"
v1.measurements(bucket: "bucket-name")
```
##### List hosts
### List hosts
List all `host` tag values in a specified bucket.
```js
import "influxdata/influxdb/v1"
v1.tagValues(bucket: "bucket-name", tag: "host")
```
##### List fields in a measurement
### List fields in a measurement
List all fields in a specified bucket and measurement.
```js
import "influxdata/influxdb/v1"
v1.measurementTagValues(bucket: "bucket-name", measurement: "measurment-name", tag: "_field")
v1.measurementTagValues(
bucket: "bucket-name",
measurement: "measurment-name",
tag: "_field"
)
```

View File

@ -11,6 +11,8 @@ weight: 201
Create dashboard variables in the Data Explorer, from the Organization page, or import a variable.
_For information about variable types, see [Variable types](/v2.0/visualize-data/variables/variable-types/)._
### Create a variable in the Data Explorer
1. Click the **Data Explorer** icon in the sidebar.

View File

@ -17,10 +17,19 @@ Variable types determine how the list of possible values is populated.
## Query
Variable values are populated using the results of a Flux query.
All values in the `_value` column are possible values for the variable.
##### Variable query example
```js
// List all buckets
buckets()
|> 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
@ -30,6 +39,4 @@ Variable values are populated using the results of a Flux query.
- The variable will only use the first table in the output stream.
Use the [`group()` function](/v2.0/reference/flux/functions/built-in/transformations/group)
to group everything into a single table.
- Flux doesnt let you have unbound queries so you have to have a timeframe on a query (range function). want to keep your range fairly limited.
- Do not use any [predefined dashboard variables](/v2.0/visualize-data/variables/#predefined-dashboard-variables) in variable queries.
{{% /note %}}

View File

@ -28,3 +28,5 @@ View a list of dashboard variables in the InfluxDB user interface (UI) from an o
2. Switch to **Script Editor**.
3. Click the **Variables** tab to the right of the script editor.
{{< img-hd src="/img/2-0-variables-data-explorer-view.png" />}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB