From c1a6611fabe4258eaa364940f98267f30d70bd33 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 23 Apr 2020 14:27:24 -0600 Subject: [PATCH 01/24] Revert "Revert "Flux 'getRecord' and 'getColumn' functions"" --- content/v2.0/query-data/flux/scalar-values.md | 103 +++++++----------- .../built-in/transformations/columns.md | 2 +- .../built-in/transformations/cumulativesum.md | 2 +- .../stdlib/built-in/transformations/drop.md | 2 +- .../built-in/transformations/duplicate.md | 2 +- .../built-in/transformations/elapsed.md | 2 +- .../stdlib/built-in/transformations/fill.md | 2 +- .../stdlib/built-in/transformations/filter.md | 2 +- .../stdlib/built-in/transformations/group.md | 2 +- .../built-in/transformations/histogram.md | 2 +- .../built-in/transformations/hourselection.md | 2 +- .../stdlib/built-in/transformations/join.md | 2 +- .../stdlib/built-in/transformations/keep.md | 2 +- .../stdlib/built-in/transformations/keys.md | 2 +- .../built-in/transformations/keyvalues.md | 2 +- .../stdlib/built-in/transformations/limit.md | 2 +- .../stdlib/built-in/transformations/map.md | 2 +- .../stdlib/built-in/transformations/pivot.md | 2 +- .../stdlib/built-in/transformations/range.md | 2 +- .../stdlib/built-in/transformations/rename.md | 2 +- .../stdlib/built-in/transformations/set.md | 2 +- .../stdlib/built-in/transformations/sort.md | 2 +- .../built-in/transformations/statecount.md | 2 +- .../built-in/transformations/stateduration.md | 2 +- .../transformations/stream-table/_index.md | 30 ++++- .../stream-table/findcolumn.md | 54 +++++++++ .../stream-table/findrecord.md | 54 +++++++++ .../transformations/stream-table/getcolumn.md | 2 +- .../transformations/stream-table/getrecord.md | 2 +- .../transformations/stream-table/tablefind.md | 2 +- .../stdlib/built-in/transformations/tail.md | 2 +- .../built-in/transformations/timeshift.md | 2 +- .../transformations/truncatetimecolumn.md | 2 +- .../stdlib/built-in/transformations/union.md | 2 +- .../stdlib/built-in/transformations/window.md | 2 +- 35 files changed, 203 insertions(+), 100 deletions(-) create mode 100644 content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md create mode 100644 content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md diff --git a/content/v2.0/query-data/flux/scalar-values.md b/content/v2.0/query-data/flux/scalar-values.md index ff1458b2e..b2fbdd280 100644 --- a/content/v2.0/query-data/flux/scalar-values.md +++ b/content/v2.0/query-data/flux/scalar-values.md @@ -22,9 +22,9 @@ This lets you, for example, dynamically set variables using query results. **To extract scalar values from output:** -1. [Extract a table](#extract-a-table). -2. [Extract a column from the table](#extract-a-column-from-the-table) - _**or**_ [extract a row from the table](#extract-a-row-from-the-table). +1. [Extract a column from the input stream](#extract-a-column) + _**or**_ [extract a row from the input stream](#extract-a-row). +2. Use the returned array or object to reference scalar values. _The samples on this page use the [sample data provided below](#sample-data)._ @@ -38,61 +38,33 @@ _The samples on this page use the [sample data provided below](#sample-data)._ See [#15321](https://github.com/influxdata/influxdb/issues/15231). {{% /warn %}} -## Extract a table +## Table extraction Flux formats query results as a stream of tables. -To extract a scalar value from a stream of tables, you must first extract a single table. - -to extract a single table from the stream of tables. - -{{% note %}} -If query results include only one table, it is still formatted as a stream of tables. -You still must extract that table from the stream. -{{% /note %}} - -Use [`tableFind()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/) -to extract the **first** table whose [group key](/v2.0/reference/glossary/#group-key) -values match the `fn` [predicate function](/v2.0/reference/glossary/#predicate-expression). -The predicate function requires a `key` object, which represents the group key of -each table. - -```js -sampleData - |> tableFind(fn: (key) => - key._field == "temp" and - key.location == "sfo" - ) -``` - -The example above returns a single table: - -| _time | location | _field | _value | -|:----- |:--------:|:------:| ------:| -| 2019-11-01T12:00:00Z | sfo | temp | 65.1 | -| 2019-11-01T13:00:00Z | sfo | temp | 66.2 | -| 2019-11-01T14:00:00Z | sfo | temp | 66.3 | -| 2019-11-01T15:00:00Z | sfo | temp | 66.8 | +Both [`findColumn()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/) +and [`findRecord()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/) +extract the first table in a stream of tables whose [group key](/v2.0/reference/glossary/#group-key) +values match the `fn` [predicate function](/v2.0/reference/glossary/#predicate-function). {{% note %}} #### Extract the correct table -Flux functions do not guarantee table order and `tableFind()` returns only the -**first** table that matches the `fn` predicate. -To extract the table that includes the data you actually want, be very specific in -your predicate function or filter and transform your data to minimize the number -of tables piped-forward into `tableFind()`. +Flux functions do not guarantee table order. +`findColumn()` and `findRecord` extract only the **first** table that matches the `fn` predicate. +To extract the correct table, be very specific in your predicate function or +filter and transform your data to minimize the number of tables piped-forward into the functions. {{% /note %}} -## Extract a column from the table -Use the [`getColumn()` function](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn/) +## Extract a column +Use the [`findColumn()` function](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/) to output an array of values from a specific column in the extracted table. +_See [Sample data](#sample-data) below._ ```js sampleData - |> tableFind(fn: (key) => - key._field == "temp" and - key.location == "sfo" + |> findColumn( + fn: (key) => key._field == "temp" and key.location == "sfo", + column: "_value" ) - |> getColumn(column: "_value") // Returns [65.1, 66.2, 66.3, 66.8] ``` @@ -103,13 +75,14 @@ In the example below, `SFOTemps` represents the array of values. Reference a specific index (integer starting from `0`) in the array to return the value at that index. +_See [Sample data](#sample-data) below._ + ```js SFOTemps = sampleData - |> tableFind(fn: (key) => - key._field == "temp" and - key.location == "sfo" + |> findColumn( + fn: (key) => key._field == "temp" and key.location == "sfo", + column: "_value" ) - |> getColumn(column: "_value") SFOTemps // Returns [65.1, 66.2, 66.3, 66.8] @@ -121,19 +94,18 @@ SFOTemps[2] // Returns 66.3 ``` -## Extract a row from the table -Use the [`getRecord()` function](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/) +## Extract a row +Use the [`findRecord()` function](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/) to output data from a single row in the extracted table. Specify the index of the row to output using the `idx` parameter. The function outputs an object with key-value pairs for each column. ```js sampleData - |> tableFind(fn: (key) => - key._field == "temp" and - key.location == "sfo" + |> findRecord( + fn: (key) => key._field == "temp" and key.location == "sfo", + idx: 0 ) - |> getRecord(idx: 0) // Returns { // _time:2019-11-11T12:00:00Z, @@ -151,11 +123,10 @@ keys in the object. ```js tempInfo = sampleData - |> tableFind(fn: (key) => - key._field == "temp" and - key.location == "sfo" + |> findRecord( + fn: (key) => key._field == "temp" and key.location == "sfo", + idx: 0 ) - |> getRecord(idx: 0) tempInfo // Returns { @@ -180,8 +151,10 @@ Create custom helper functions to extract scalar values from query output. // Define a helper function to extract field values getFieldValue = (tables=<-, field) => { extract = tables - |> tableFind(fn: (key) => key._field == field) - |> getColumn(column: "_value") + |> findColumn( + fn: (key) => key._field == field, + column: "_value" + ) return extract[0] } @@ -200,8 +173,10 @@ lastJFKTemp // Define a helper function to extract a row as an object getRow = (tables=<-, field, idx=0) => { extract = tables - |> tableFind(fn: (key) => true) - |> getRecord(idx: idx) + |> findRecord( + fn: (key) => true, + idx: idx + ) return extract } diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/columns.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/columns.md index 2703ce387..f422cd379 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/columns.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/columns.md @@ -11,7 +11,7 @@ menu: v2_0_ref: name: columns parent: built-in-transformations -weight: 401 +weight: 402 --- The `columns()` function lists the column labels of input tables. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/cumulativesum.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/cumulativesum.md index 72d4087e6..d0d67d25d 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/cumulativesum.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/cumulativesum.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: cumulativeSum parent: built-in-transformations -weight: 401 +weight: 402 --- The `cumulativeSum()` function computes a running sum for non-null records in the table. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/drop.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/drop.md index 2c2f70133..dc78afa67 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/drop.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/drop.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: drop parent: built-in-transformations -weight: 401 +weight: 402 --- The `drop()` function removes specified columns from a table. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/duplicate.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/duplicate.md index cbc060dc0..db6a2ebc1 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/duplicate.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/duplicate.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: duplicate parent: built-in-transformations -weight: 401 +weight: 402 --- The `duplicate()` function duplicates a specified column in a table. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/elapsed.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/elapsed.md index b297476c2..e4adcbc2e 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/elapsed.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/elapsed.md @@ -7,7 +7,7 @@ menu: v2_0_ref: name: elapsed parent: built-in-transformations -weight: 401 +weight: 402 --- The `elapsed()` function returns the time between subsequent records. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/fill.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/fill.md index 9cd01d630..6995e5431 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/fill.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/fill.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: fill parent: built-in-transformations -weight: 401 +weight: 402 --- The `fill()` function replaces all null values in an input stream with a non-null value. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/filter.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/filter.md index 6f16a5c6e..b27ac3534 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/filter.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/filter.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: filter parent: built-in-transformations -weight: 401 +weight: 402 v2.0/tags: [exists] --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md index f968ed990..b562ed502 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: group parent: built-in-transformations -weight: 401 +weight: 402 --- The `group()` function groups records based on their values for specific columns. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/histogram.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/histogram.md index a4e04bb96..b6008b9a8 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/histogram.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/histogram.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: histogram parent: built-in-transformations -weight: 401 +weight: 402 --- The `histogram()` function approximates the cumulative distribution of a dataset by counting data frequencies for a list of bins. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/hourselection.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/hourselection.md index b56ad99f5..ee53fa130 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/hourselection.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/hourselection.md @@ -10,7 +10,7 @@ menu: v2_0_ref: name: hourSelection parent: built-in-transformations -weight: 401 +weight: 402 --- The `hourSelection()` function retains all rows with time values in a specified hour range. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/join.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/join.md index b9ce02ff4..6bc214e5e 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/join.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/join.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: join parent: built-in-transformations -weight: 401 +weight: 402 related: - /v2.0/reference/flux/stdlib/built-in/transformations/union/ --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/keep.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/keep.md index 6c4f0dada..94c7e6d29 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/keep.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/keep.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: keep parent: built-in-transformations -weight: 401 +weight: 402 --- The `keep()` function returns a table containing only the specified columns, ignoring all others. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/keys.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/keys.md index 5f82e10b3..d7b7f3857 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/keys.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/keys.md @@ -11,7 +11,7 @@ menu: v2_0_ref: name: keys parent: built-in-transformations -weight: 401 +weight: 402 --- The `keys()` function outputs the group key of input tables. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/keyvalues.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/keyvalues.md index 3db7044bc..6a1a4ee11 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/keyvalues.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/keyvalues.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: keyValues parent: built-in-transformations -weight: 401 +weight: 402 --- The `keyValues()` function returns a table with the input table's group key plus two columns, diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/limit.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/limit.md index dd7915862..ec5131863 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/limit.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/limit.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: limit parent: built-in-transformations -weight: 401 +weight: 402 related: - /v2.0/reference/flux/stdlib/built-in/transformations/tail/ - https://docs.influxdata.com/influxdb/latest/query_language/data_exploration/#the-limit-and-slimit-clauses, InfluxQL LIMIT diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/map.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/map.md index b5327c361..102f49bb5 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/map.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/map.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: map parent: built-in-transformations -weight: 401 +weight: 402 v2.0/tags: [exists] --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/pivot.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/pivot.md index db5538ce3..9081d2d6b 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/pivot.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/pivot.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: pivot parent: built-in-transformations -weight: 401 +weight: 402 --- The `pivot()` function collects values stored vertically (column-wise) in a table diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/range.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/range.md index 56d467646..f78588d1b 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/range.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/range.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: range parent: built-in-transformations -weight: 401 +weight: 402 --- The `range()` function filters records based on time bounds. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/rename.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/rename.md index 57e3c504f..8f34a8f0c 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/rename.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/rename.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: rename parent: built-in-transformations -weight: 401 +weight: 402 --- The `rename()` function renames specified columns in a table. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/set.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/set.md index 812bc21b0..0354cbdf5 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/set.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/set.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: set parent: built-in-transformations -weight: 401 +weight: 402 --- The `set()` function assigns a static value to each record in the input table. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/sort.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/sort.md index a4a6f4e1d..9b583eb82 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/sort.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/sort.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: sort parent: built-in-transformations -weight: 401 +weight: 402 --- The `sort()` function orders the records within each table. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/statecount.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/statecount.md index 58966ae86..e38f233df 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/statecount.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/statecount.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: stateCount parent: built-in-transformations -weight: 401 +weight: 402 --- The `stateCount()` function computes the number of consecutive records in a given state. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stateduration.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stateduration.md index fb62eb1d8..30eebac87 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/stateduration.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stateduration.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: stateDuration parent: built-in-transformations -weight: 401 +weight: 402 --- The `stateDuration()` function computes the duration of a given state. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/_index.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/_index.md index c1c0f1382..f64bccad1 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/_index.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/_index.md @@ -13,16 +13,38 @@ menu: name: Stream & table parent: built-in-transformations v2.0/tags: [transformations, built-in, functions, stream, table] +related: + - /v2.0/query-data/flux/scalar-values/ --- Use stream and table functions to extract a table from a stream of tables and access its columns and records. -##### Example stream and table functions +{{< children type="functions" >}} + +### Example stream and table functions + +##### Recommended usage ```js data = from(bucket:"example-bucket") - |> range(start: -5m) - |> filter(fn:(r) => r._measurement == "cpu") + |> range(start: -5m) + |> filter(fn:(r) => r._measurement == "cpu") + +// Extract the "_value" column from the table +data + |> findColumn(fn: (key) => key._field == "usage_idle", column: "_value") + +// Extract the first record from the table +data + |> findRecord(fn: (key) => key._field == "usage_idle", idx: 0) + +``` + +##### Alternate usage +```js +data = from(bucket:"example-bucket") + |> range(start: -5m) + |> filter(fn:(r) => r._measurement == "cpu") // Extract the first available table for which "_field" is equal to "usage_idle" t = data |> tableFind(fn: (key) => key._field == "usage_idle") @@ -33,5 +55,3 @@ values = t |> getColumn(column: "_value") // Extract the first record from the table r0 = t |> getRecord(idx: 0) ``` - -{{< children type="functions" >}} diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md new file mode 100644 index 000000000..53310e3b8 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn.md @@ -0,0 +1,54 @@ +--- +title: findColumn() function +description: > + The `findColumn()` function returns an array of values in a specified column from the + first table in a stream of tables where group key values match the specified predicate. +menu: + v2_0_ref: + name: findColumn + parent: Stream & table +weight: 501 +related: + - /v2.0/query-data/flux/scalar-values/ +--- + +The `findColumn()` function returns an array of values in a specified column from the +first table in a stream of tables where the group key values match the specified predicate. +The function returns an empty array if no table is found or if the column label +is not present in the set of columns. + +_**Function type:** Stream and table_ + +```js +findColumn( + fn: (key) => key._field == "fieldName") + column: "_value" +) +``` + +## Parameters + +### fn +A predicate function for matching keys in a table's group key. +Expects a `key` argument that represents a group key in the input stream. + +_**Data type:** Function_ + +### column +Name of the column to extract. + +_**Data type:** String_ + +## Example +```js +vs = from(bucket:"example-bucket") + |> range(start: -5m) + |> filter(fn:(r) => r._measurement == "cpu") + |> findColumn( + fn: (key) => key._field == "usage_idle", + column: "_value" + ) + +// Use column values +x = vs[0] + vs[1] +``` diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md new file mode 100644 index 000000000..edf2f8a56 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord.md @@ -0,0 +1,54 @@ +--- +title: findRecord() function +description: > + The `findRecord()` function returns a record at a specified index from the first + table in a stream of tables where the group key values match the specified predicate. +menu: + v2_0_ref: + name: findRecord + parent: Stream & table +weight: 501 +related: + - /v2.0/query-data/flux/scalar-values/ +--- + +The `findRecord()` function returns a record at a specified index from the first +table in a stream of tables where the group key values match the specified predicate. +The function returns an empty object if no table is found or if the index is out of bounds. + +_**Function type:** Stream and table_ + +```js +findRecord( + fn: (key) => key._field == "fieldName", + idx: 0 +) +``` + +## Parameters + +### fn +A predicate function for matching keys in a table's group key. +Expects a `key` argument that represents a group key in the input stream. + +_**Data type:** Function_ + +### idx +Index of the record to extract. + +_**Data type:** Integer_ + +## Example +```js +r0 = from(bucket:"example-bucket") + |> range(start: -5m) + |> filter(fn:(r) => r._measurement == "cpu") + |> tableFind() + |> findRecord( + fn: (key) => key._field == "usage_idle", + idx: 0 + ) + +// Use record values +x = r0._field + "--" + r0._measurement +``` diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md index cbc976099..9057e2f8a 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getcolumn.md @@ -31,7 +31,7 @@ to extract a single table from a stream of tables. ## Parameters ### column -The name of the column to extract. +Name of the column to extract. _**Data type:** String_ diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md index f660be331..6823f4cfd 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/getrecord.md @@ -31,7 +31,7 @@ to extract a single table from a stream of tables. ## Parameters ### idx -The index of the record to extract. +Index of the record to extract. _**Data type:** Integer_ diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md index 409ea3dbc..526dfbd1d 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/tablefind.md @@ -32,7 +32,7 @@ To learn why, see [Match parameter names](/v2.0/reference/flux/language/data-mod A predicate function for matching keys in a table's group key. `tableFind` returns the first table that resolves as `true`. -It expects a `key` argument which represents a group key in the input stream. +Expects a `key` argument that represents a group key in the input stream. _**Data type:** Function_ diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/tail.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/tail.md index b86287b1b..fe975298e 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/tail.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/tail.md @@ -7,7 +7,7 @@ menu: v2_0_ref: name: tail parent: built-in-transformations -weight: 401 +weight: 402 related: - /v2.0/reference/flux/functions/built-in/transformations/limit/ --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/timeshift.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/timeshift.md index be365a397..624fe3b8a 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/timeshift.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/timeshift.md @@ -9,7 +9,7 @@ menu: v2_0_ref: name: timeShift parent: built-in-transformations -weight: 401 +weight: 402 --- The `timeShift()` function adds a fixed duration to time columns. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/truncatetimecolumn.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/truncatetimecolumn.md index 6b0a0b053..63df2ba40 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/truncatetimecolumn.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/truncatetimecolumn.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: truncateTimeColumn parent: built-in-transformations -weight: 401 +weight: 402 related: - /v2.0/reference/flux/stdlib/date/truncate/ --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/union.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/union.md index f2ed1030a..529bc546e 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/union.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/union.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: union parent: built-in-transformations -weight: 401 +weight: 402 related: - /v2.0/reference/flux/stdlib/built-in/transformations/join/ --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/window.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/window.md index 6611b35a6..d1c611703 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/window.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/window.md @@ -8,7 +8,7 @@ menu: v2_0_ref: name: window parent: built-in-transformations -weight: 401 +weight: 402 --- The `window()` function groups records based on a time value. From f538505ef11dcf91cea0dbc9036e1dfd924476e9 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 29 Apr 2020 10:22:10 -0600 Subject: [PATCH 02/24] added flux 0.67.0 to flux changelog --- content/v2.0/reference/release-notes/flux.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index daf7f5630..da2c34673 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -16,6 +16,22 @@ Though newer versions of Flux may be available, they will not be included with InfluxDB until the next InfluxDB v2.0 release._ {{% /note %}} +## v0.67.0 [2020-04-28] + +### Features +- Planner Pattern interface supplies a set of ProcedureKind as root. +- Initial prototype of a table-based Flux. +- Evaluate and store "now" in execution dependencies for `tableFind()` to use. +- Static analysis tool for listing entry points to Flux. +- Pass context to rewrite rules in the planner. + +### Bug fixes +- Pivot sends update watermark and processing time exactly once. +- `system.time()` checks context for override. +- Add bounds to alignTime tests. + +--- + ## v0.66.1 [2020-04-14] ### Bug fixes From e6f234bb81aae426e79eeeb9376ea528359e26bf Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Wed, 29 Apr 2020 10:24:15 -0700 Subject: [PATCH 03/24] Add clarification about token creation during setup and link to vieiwng tokens doc (adresses #985 ) --- content/v2.0/get-started.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index 21ef2a565..f06b44dba 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -381,8 +381,9 @@ You are ready to [write or collect data](/v2.0/write-data). {{% note %}} #### Using the influx CLI after setting up InfluxDB through the UI -To use the [`influx` CLI](/v2.0/reference/cli/influx) after setting up InfluxDB through the UI, -use one of the following methods to provide your [authentication token](/v2.0/users/tokens/) to the CLI: +To use the [`influx` CLI](/v2.0/reference/cli/influx) after setting up InfluxDB through the UI, provide your [authentication token](/v2.0/users/tokens/), which is automatically generated during the setup process. For instructions on viewing your token via CLI or UI, see [View tokens](/v2.0/security/tokens/view-tokens/). + +Use one of the following methods to provide your authentication token to the CLI: 1. Pass your token to the `influx` CLI using the `-t` or `--token` flag. 2. Set the `INFLUX_TOKEN` environment variable using your token. @@ -418,7 +419,7 @@ influx setup Enter nothing for an infinite retention period. 7. Confirm the details for your primary user, organization, and bucket. -InfluxDB is now initialized with a primary user, organization, and bucket. +InfluxDB is now initialized with a primary user, organization, bucket, and authentication token. (For instructions on viewing your token via CLI or UI, see [View tokens](/v2.0/security/tokens/view-tokens/).) You are ready to [write or collect data](/v2.0/write-data). {{% note %}} From 34e0d0403f38d9d4da14f6d78e987afde9de2139 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 30 Apr 2020 17:01:34 -0600 Subject: [PATCH 04/24] added snowflake support, resolves #894 --- content/v2.0/get-started.md | 4 +++ .../query-data/flux/calculate-percentages.md | 2 +- .../query-data/flux/mathematic-operations.md | 2 +- content/v2.0/query-data/flux/sql.md | 19 +++++++++++--- .../v2.0/reference/flux/stdlib/sql/_index.md | 2 +- .../v2.0/reference/flux/stdlib/sql/from.md | 23 ++++++++++++++--- content/v2.0/reference/flux/stdlib/sql/to.md | 25 ++++++++++++++++--- 7 files changed, 64 insertions(+), 13 deletions(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index 21ef2a565..dc25fc8f2 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -458,6 +458,10 @@ For details, see [Scrape data](/v2.0/write-data/scrape-data/). For information about using the InfluxDB v2 API, `influx` CLI, and client libraries to write data, see [Write data to InfluxDB](/v2.0/write-data/). +#### Demo data +If using **{{< cloud-name "short" >}}**, [add a demo data bucket](/v2.0/write-data/sample-data/demo-data/) +for quick, _free_ access to time series data. + ### Query data Query data using Flux, the UI, and the `influx` command line interface. diff --git a/content/v2.0/query-data/flux/calculate-percentages.md b/content/v2.0/query-data/flux/calculate-percentages.md index 9b594ea0e..123ff0f73 100644 --- a/content/v2.0/query-data/flux/calculate-percentages.md +++ b/content/v2.0/query-data/flux/calculate-percentages.md @@ -201,7 +201,7 @@ pgHost = secrets.get(key: "POSTGRES_HOST") t1 = sql.from( driverName: "postgres", dataSourceName: "postgresql://${pgUser}:${pgPass}@${pgHost}", - query:"SELECT id, name, available FROM exampleTable" + query:"SELECT id, name, available FROM example_table" ) t2 = from(bucket: "example-bucket") diff --git a/content/v2.0/query-data/flux/mathematic-operations.md b/content/v2.0/query-data/flux/mathematic-operations.md index 284657756..69bbb7924 100644 --- a/content/v2.0/query-data/flux/mathematic-operations.md +++ b/content/v2.0/query-data/flux/mathematic-operations.md @@ -221,7 +221,7 @@ pgHost = secrets.get(key: "POSTGRES_HOST") t1 = sql.from( driverName: "postgres", dataSourceName: "postgresql://${pgUser}:${pgPass}@${pgHost}", - query:"SELECT id, name, available FROM exampleTable" + query:"SELECT id, name, available FROM example_table" ) t2 = from(bucket: "example-bucket") diff --git a/content/v2.0/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index b769145ff..0dd7c4908 100644 --- a/content/v2.0/query-data/flux/sql.md +++ b/content/v2.0/query-data/flux/sql.md @@ -4,7 +4,7 @@ seotitle: Query SQL data sources with InfluxDB list_title: Query SQL data description: > The Flux `sql` package provides functions for working with SQL data sources. - Use `sql.from()` to query SQL databases like PostgreSQL and MySQL + Use `sql.from()` to query SQL databases like PostgreSQL, MySQL, Snowflake, and SQLite. v2.0/tags: [query, flux, sql] menu: v2_0: @@ -30,8 +30,8 @@ list_code_example: | The [Flux](/v2.0/reference/flux) `sql` package provides functions for working with SQL data sources. [`sql.from()`](/v2.0/reference/flux/stdlib/sql/from/) lets you query SQL data sources like [PostgreSQL](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), -and [SQLite](https://www.sqlite.org/index.html), and use the results with InfluxDB -dashboards, tasks, and other operations. +[Snowflake](https://www.snowflake.com/), and [SQLite](https://www.sqlite.org/index.html), +and use the results with InfluxDB dashboards, tasks, and other operations. - [Query a SQL data source](#query-a-sql-data-source) - [Join SQL data with data in InfluxDB](#join-sql-data-with-data-in-influxdb) @@ -54,6 +54,7 @@ To query a SQL data source: {{% code-tabs %}} [PostgreSQL](#) [MySQL](#) +[Snowflake](#) [SQLite](#) {{% /code-tabs %}} @@ -81,6 +82,18 @@ sql.from( ``` {{% /code-tab-content %}} +{{% code-tab-content %}} +```js +import "sql" + +sql.from( + driverName: "snowflake", + dataSourceName: "user:password@account/db/exampleschema?warehouse=wh", + query: "SELECT * FROM example_table" +) +``` +{{% /code-tab-content %}} + {{% code-tab-content %}} ```js // NOTE: InfluxDB OSS and InfluxDB Cloud do not have access to diff --git a/content/v2.0/reference/flux/stdlib/sql/_index.md b/content/v2.0/reference/flux/stdlib/sql/_index.md index 51d3d2c9b..2fd8814e0 100644 --- a/content/v2.0/reference/flux/stdlib/sql/_index.md +++ b/content/v2.0/reference/flux/stdlib/sql/_index.md @@ -18,7 +18,7 @@ related: --- SQL Flux functions provide tools for working with data in SQL databases such as -MySQL, PostgreSQL, and SQLite. +MySQL, PostgreSQL, Snowflake, and SQLite. Import the `sql` package: ```js diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index 7e2518a27..3c231cf74 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -37,6 +37,7 @@ The following drivers are available: - mysql - postgres +- snowflake - sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#query-an-sqlite-database)._ ### dataSourceName @@ -53,6 +54,11 @@ postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full # MySQL Driver DSN username:password@tcp(localhost:3306)/dbname?param=value +# Snowflake Driver DSNs +username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN +username[:password]@accountname/dbname?param1=value1¶mN=valueN +username[:password]@hostname:port/dbname/schemaname?account=¶m1=value1¶mN=valueN + # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=ro ``` @@ -71,7 +77,7 @@ import "sql" sql.from( driverName: "mysql", dataSourceName: "user:password@tcp(localhost:3306)/db", - query:"SELECT * FROM ExampleTable" + query: "SELECT * FROM example_table" ) ``` @@ -82,7 +88,18 @@ import "sql" sql.from( driverName: "postgres", dataSourceName: "postgresql://user:password@localhost", - query:"SELECT * FROM ExampleTable" + query: "SELECT * FROM example_table" +) +``` + +### Query a Snowflake database +```js +import "sql" + +sql.from( + driverName: "snowflake", + dataSourceName: "user:password@account/db/exampleschema?warehouse=wh", + query: "SELECT * FROM example_table" ) ``` @@ -101,6 +118,6 @@ import "sql" sql.from( driverName: "sqlite3", dataSourceName: "file:/path/to/test.db?cache=shared&mode=ro", - query:"SELECT * FROM ExampleTable" + query: "SELECT * FROM example_table" ) ``` diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index 4d4552bf2..754fb6e93 100644 --- a/content/v2.0/reference/flux/stdlib/sql/to.md +++ b/content/v2.0/reference/flux/stdlib/sql/to.md @@ -20,7 +20,7 @@ import "sql" sql.to( driverName: "mysql", dataSourceName: "username:password@tcp(localhost:3306)/dbname?param=value", - table: "ExampleTable", + table: "example_table", batchSize: 10000 ) ``` @@ -36,6 +36,7 @@ The following drivers are available: - mysql - postgres +- snowflake - sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#write-data-to-an-sqlite-database)._ ### dataSourceName @@ -52,6 +53,11 @@ postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full # MySQL Driver DSN username:password@tcp(localhost:3306)/dbname?param=value +# Snowflake Driver DSNs +username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN +username[:password]@accountname/dbname?param1=value1¶mN=valueN +username[:password]@hostname:port/dbname/schemaname?account=¶m1=value1¶mN=valueN + # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=rw ``` @@ -80,7 +86,7 @@ import "sql" sql.to( driverName: "mysql", dataSourceName: "user:password@tcp(localhost:3306)/db", - table: "ExampleTable" + table: "example_table" ) ``` @@ -91,7 +97,18 @@ import "sql" sql.to( driverName: "postgres", dataSourceName: "postgresql://user:password@localhost", - table: "ExampleTable" + table: "example_table" +) +``` + +### Write data to a Snowflake database +```js +import "sql" + +sql.to( + driverName: "snowflake", + dataSourceName: "user:password@account/db/exampleschema?warehouse=wh", + table: "example_table" ) ``` @@ -110,6 +127,6 @@ import "sql" sql.to( driverName: "sqlite3", dataSourceName: "file:/path/to/test.db?cache=shared&mode=rw", - table: "ExampleTable" + table: "example_table" ) ``` From 9d08b897a753e5574f35f219eb9f4b79918f0cc2 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 30 Apr 2020 17:04:06 -0600 Subject: [PATCH 05/24] removed demo data section from getting started --- content/v2.0/get-started.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index dc25fc8f2..21ef2a565 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -458,10 +458,6 @@ For details, see [Scrape data](/v2.0/write-data/scrape-data/). For information about using the InfluxDB v2 API, `influx` CLI, and client libraries to write data, see [Write data to InfluxDB](/v2.0/write-data/). -#### Demo data -If using **{{< cloud-name "short" >}}**, [add a demo data bucket](/v2.0/write-data/sample-data/demo-data/) -for quick, _free_ access to time series data. - ### Query data Query data using Flux, the UI, and the `influx` command line interface. From dbd49f8f7467455a77b471f82ecb9e92b2e56456 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 7 May 2020 11:31:45 -0600 Subject: [PATCH 06/24] added schema exploration query guide --- .../query-data/flux/calculate-percentages.md | 2 +- .../v2.0/query-data/flux/explore-schema.md | 141 ++++++++++++++++++ .../query-data/flux/mathematic-operations.md | 2 +- 3 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 content/v2.0/query-data/flux/explore-schema.md diff --git a/content/v2.0/query-data/flux/calculate-percentages.md b/content/v2.0/query-data/flux/calculate-percentages.md index 9b594ea0e..245adcb49 100644 --- a/content/v2.0/query-data/flux/calculate-percentages.md +++ b/content/v2.0/query-data/flux/calculate-percentages.md @@ -9,7 +9,7 @@ menu: v2_0: name: Calculate percentages parent: Query with Flux -weight: 206 +weight: 209 aliases: - /v2.0/query-data/guides/manipulate-timestamps/ related: diff --git a/content/v2.0/query-data/flux/explore-schema.md b/content/v2.0/query-data/flux/explore-schema.md new file mode 100644 index 000000000..d324889af --- /dev/null +++ b/content/v2.0/query-data/flux/explore-schema.md @@ -0,0 +1,141 @@ +--- +title: Explore your data schema with Flux +list_title: Explore your schema +description: > + Flux provides functions that let you explore the structure and schema of your + data stored in InfluxDB. +v2.0/tags: [schema] +menu: + v2_0: + name: Explore your schema + parent: Query with Flux +weight: 206 +related: + - /v2.0/reference/flux/stdlib/built-in/inputs/buckets/ + - /v2.0/reference/flux/stdlib/influxdb-v1/measurements + - /v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys + - /v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys + - /v2.0/reference/flux/stdlib/influxdb-v1/tagkeys + - /v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys + - /v2.0/reference/flux/stdlib/influxdb-v1/tagvalues + - /v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues +list_code_example: | + ```js + import "influxdata/influxdb/v1" + + // List buckets + buckets() + + // List measurements + v1.measurements(bucket: "example-bucket") + + // List field keys + v1.fieldKeys(bucket: "example-bucket") + + // List tag keys + v1.tagKeys(bucket: "example-bucket") + + // List tag values + v1.tagValues(bucket: "example-bucket", tag: "example-tag") + ``` +--- + +Flux provides functions that let you explore the structure and schema of your +data stored in InfluxDB. + +- [List buckets](#list-buckets) +- [List measurements](#list-measurements) +- [List field keys](#list-field-keys) +- [List tag keys](#list-tag-keys) +- [List tag values](#list-tag-values) + +## List buckets +Use the [`buckets()` function](/v2.0/reference/flux/stdlib/built-in/inputs/buckets/) +to list **buckets in your organization**. + +```js +buckets() +``` + +## List measurements +Use the [`v1.measurements()` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurements) +to list **measurements in a bucket**. + +```js +import "influxdata/influxdb/v1" + +v1.measurements(bucket: "example-bucket") +``` + +## List field keys +Use the [`v1.fieldKeys` function](/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys) +to list **field keys in a bucket**. + +```js +import "influxdata/influxdb/v1" + +v1.fieldKeys(bucket: "example-bucket") +``` + +### List fields in a measurement +Use the [`v1.measurementFieldKeys` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys) +to list **field keys in a measurement**. + +```js +import "influxdata/influxdb/v1" + +v1.measurementFieldKeys( + bucket: "example-bucket", + measurement: "example-measurement" +) +``` + +## List tag keys +Use the [`v1.tagKeys()` function](/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys) +to list **tag keys in a bucket**. + +```js +import "influxdata/influxdb/v1" + +v1.tagKeys(bucket: "example-bucket") +``` + +### List tag keys in a measurement +Use the [`v1.measurementTagKeys`](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys) +to list **tag keys in a measurement**. + +- from the last 30 days + +```js +import "influxdata/influxdb/v1" + +v1.measurementTagKeys( + bucket: "example-bucket", + measurement: "example-measurement" +) +``` + +## List tag values +Use the [`v1.tagValues()` function](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues) +to list **tag values for a given tag in a bucket**. + +```js +import "influxdata/influxdb/v1" + +v1.tagValues(bucket: "example-bucket", tag: "example-tag") +``` + +### List tag values in a measurement +Use the [`v1.measurementTagValues`](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues) +to list **tag values for a given tag in a measurement**. +- from the last 30 days + +```js +import "influxdata/influxdb/v1" + +v1.measurementTagValues( + bucket: "example-bucket", + tag: "example-tag", + measurement: "example-measurement" +) +``` diff --git a/content/v2.0/query-data/flux/mathematic-operations.md b/content/v2.0/query-data/flux/mathematic-operations.md index 284657756..d3134c9d3 100644 --- a/content/v2.0/query-data/flux/mathematic-operations.md +++ b/content/v2.0/query-data/flux/mathematic-operations.md @@ -10,7 +10,7 @@ menu: v2_0: name: Transform data with math parent: Query with Flux -weight: 205 +weight: 208 aliases: - /v2.0/query-data/guides/mathematic-operations/ related: From 039bc96176003582f3282bfa1fca4285c831db7c Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 7 May 2020 11:56:30 -0600 Subject: [PATCH 07/24] added v1.fieldKeys and v1.measurementFieldKeys docs, resolves #1016, resolves #1003 --- .../v2.0/query-data/flux/explore-schema.md | 9 ++- .../flux/stdlib/influxdb-v1/fieldkeys.md | 67 ++++++++++++++++++ .../flux/stdlib/influxdb-v1/fieldsascols.md | 2 + .../influxdb-v1/measurementfieldkeys.md | 69 +++++++++++++++++++ .../flux/stdlib/influxdb-v1/measurements.md | 5 +- .../stdlib/influxdb-v1/measurementtagkeys.md | 8 ++- .../influxdb-v1/measurementtagvalues.md | 5 +- .../flux/stdlib/influxdb-v1/tagkeys.md | 5 +- .../flux/stdlib/influxdb-v1/tagvalues.md | 7 +- 9 files changed, 165 insertions(+), 12 deletions(-) create mode 100644 content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md create mode 100644 content/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys.md diff --git a/content/v2.0/query-data/flux/explore-schema.md b/content/v2.0/query-data/flux/explore-schema.md index d324889af..c199c231f 100644 --- a/content/v2.0/query-data/flux/explore-schema.md +++ b/content/v2.0/query-data/flux/explore-schema.md @@ -101,10 +101,9 @@ v1.tagKeys(bucket: "example-bucket") ``` ### List tag keys in a measurement -Use the [`v1.measurementTagKeys`](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys) +Use the [`v1.measurementTagKeys` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys) to list **tag keys in a measurement**. - -- from the last 30 days +_This function returns results from the last 30 days._ ```js import "influxdata/influxdb/v1" @@ -126,9 +125,9 @@ v1.tagValues(bucket: "example-bucket", tag: "example-tag") ``` ### List tag values in a measurement -Use the [`v1.measurementTagValues`](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues) +Use the [`v1.measurementTagValues` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues) to list **tag values for a given tag in a measurement**. -- from the last 30 days +_This function returns results from the last 30 days._ ```js import "influxdata/influxdb/v1" diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md new file mode 100644 index 000000000..1f3cf1155 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md @@ -0,0 +1,67 @@ +--- +title: v1.fieldKeys() function +description: The `v1.fieldKeys()` function returns a list of fields in a bucket. +menu: + v2_0_ref: + name: v1.fieldKeys + parent: InfluxDB v1 +weight: 301 +v2.0/tags: [fields] +related: + - /v2.0/query-data/flux/explore-schema/ + - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-field-keys, SHOW FIELD KEYS in InfluxQL +--- + +The `v1.fieldKeys()` function returns a list of fields in a bucket. +The return value is always a single table with a single column, `_value`. + +```js +import "influxdata/influxdb/v1" + +v1.fieldKeys( + bucket: "example-bucket", + predicate: (r) => true, + start: -30d +) +``` + +## Parameters + +### bucket +The bucket to list field keys from. + +_**Data type:** String_ + +### predicate +The predicate function that filters field keys. +_Defaults to `(r) => true`._ + +_**Data type:** Function_ + +### start +The oldest time to include in results. +_Defaults to `-30d`._ + +Relative start times are defined using negative durations. +Negative durations are relative to now. +Absolute start times are defined using timestamps. + +_**Data type:** Duration_ + +## Examples +```js +import "influxdata/influxdb/v1" + +v1.fieldKeys(bucket: "my-bucket") +``` + +## Function definition +```js +package v1 + +fieldKeys = (bucket, predicate=(r) => true, start=-30d) => + tagValues(bucket: bucket, tag: "_field", predicate: predicate, start: start) +``` + +_**Used functions:** +[v1.tagValues](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues/)_ diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldsascols.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldsascols.md index a1596f8a6..13c4df176 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldsascols.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldsascols.md @@ -36,6 +36,8 @@ from(bucket:"example-bucket") ## Function definition ```js +package v1 + fieldsAsCols = (tables=<-) => tables |> pivot( diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys.md new file mode 100644 index 000000000..519c91216 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys.md @@ -0,0 +1,69 @@ +--- +title: v1.measurementFieldKeys() function +description: The `v1.measurementFieldKeys()` function returns a list of fields in a measurement. +menu: + v2_0_ref: + name: v1.measurementFieldKeys + parent: InfluxDB v1 +weight: 301 +v2.0/tags: [fields] +related: + - /v2.0/query-data/flux/explore-schema/ + - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-field-keys, SHOW FIELD KEYS in InfluxQL +--- + +The `v1.measurementFieldKeys()` function returns a list of fields in a measurement. +The return value is always a single table with a single column, `_value`. + +```js +import "influxdata/influxdb/v1" + +v1.measurementFieldKeys( + bucket: "example-bucket", + measurement: "example-measurement", + start: -30d +) +``` + +## Parameters + +### bucket +The bucket to list field keys from. + +_**Data type:** String_ + +### measurement +The measurement to list field keys from. + +_**Data type:** String_ + +### start +The oldest time to include in results. +_Defaults to `-30d`._ + +Relative start times are defined using negative durations. +Negative durations are relative to now. +Absolute start times are defined using timestamps. + +_**Data type:** Duration_ + +## Examples +```js +import "influxdata/influxdb/v1" + +v1.measurementFieldKeys( + bucket: "telegraf", + measurement: "cpu", +) +``` + +## Function definition +```js +package v1 + +measurementFieldKeys = (bucket, measurement, start=-30d) => + fieldKeys(bucket: bucket, predicate: (r) => r._measurement == measurement, start: start) +``` + +_**Used functions:** +[v1.fieldKeys](/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys/)_ diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurements.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurements.md index 55143bda3..d7e113fe5 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurements.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurements.md @@ -10,6 +10,7 @@ menu: weight: 301 v2.0/tags: [measurements] related: + - /v2.0/query-data/flux/explore-schema/ - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-measurements, SHOW MEASUREMENTS in InfluxQL --- @@ -31,9 +32,11 @@ _**Data type:** String_ ## Function definition ```js +package v1 + measurements = (bucket) => tagValues(bucket: bucket, tag: "_measurement") ``` _**Used functions:** -[tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_ +[v1.tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_ diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys.md index ae6f20774..b1480d09e 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys.md @@ -10,6 +10,7 @@ menu: weight: 301 v2.0/tags: [tags] related: + - /v2.0/query-data/flux/explore-schema/ - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-keys, SHOW TAG KEYS in InfluxQL --- @@ -39,11 +40,14 @@ _**Data type:** String_ ## Function definition ```js +package v1 + measurementTagKeys = (bucket, measurement) => tagKeys( bucket: bucket, - predicate: (r) => r._measurement == measurement) + predicate: (r) => r._measurement == measurement + ) ``` _**Used functions:** -[tagKeys()](/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys)_ +[v1.tagKeys()](/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys)_ diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues.md index 9d51d7a9e..701c42b35 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues.md @@ -10,6 +10,7 @@ menu: weight: 301 v2.0/tags: [tags] related: + - /v2.0/query-data/flux/explore-schema/ - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-values, SHOW TAG VALUES in InfluxQL --- @@ -48,6 +49,8 @@ _**Data type:** String_ ## Function definition ```js +package v1 + measurementTagValues = (bucket, measurement, tag) => tagValues( bucket: bucket, @@ -57,4 +60,4 @@ measurementTagValues = (bucket, measurement, tag) => ``` _**Used functions:** -[tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_ +[v1.tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_ diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys.md index 46bc4f8d0..f523c753b 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys.md @@ -10,6 +10,7 @@ menu: weight: 301 v2.0/tags: [tags] related: + - /v2.0/query-data/flux/explore-schema/ - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-keys, SHOW TAG KEYS in InfluxQL --- @@ -40,7 +41,7 @@ _Defaults to `(r) => true`._ _**Data type:** Function_ ### start -Specifies the oldest time to be included in the results. +The oldest time to include in results. _Defaults to `-30d`._ Relative start times are defined using negative durations. @@ -59,6 +60,8 @@ v1.tagKeys(bucket: "my-bucket") ## Function definition ```js +package v1 + tagKeys = (bucket, predicate=(r) => true, start=-30d) => from(bucket: bucket) |> range(start: start) diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues.md index e07f53827..35ba8e1ee 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues.md @@ -10,6 +10,7 @@ menu: weight: 301 v2.0/tags: [tags] related: + - /v2.0/query-data/flux/explore-schema/ - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-values, SHOW TAG VALUES in InfluxQL --- @@ -46,7 +47,7 @@ _Defaults to `(r) => true`._ _**Data type:** Function_ ### start -Specifies the oldest time to be included in the results. +The oldest time to include in results. _Defaults to `-30d`._ Relative start times are defined using negative durations. @@ -59,7 +60,7 @@ _**Data type:** Duration_ ```js import "influxdata/influxdb/v1" -v1.tagKeys( +v1.tagValues( bucket: "my-bucket", tag: "host", ) @@ -67,6 +68,8 @@ v1.tagKeys( ## Function definition ```js +package v1 + tagValues = (bucket, tag, predicate=(r) => true, start=-30d) => from(bucket: bucket) |> range(start: start) From 084f1a2512375eaa896ef4f64a02371ae661b100 Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Wed, 20 May 2020 14:06:20 -0700 Subject: [PATCH 08/24] Add details on getting token to CLI setup instructions --- content/v2.0/get-started.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index f06b44dba..cdee2e640 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -419,7 +419,10 @@ influx setup Enter nothing for an infinite retention period. 7. Confirm the details for your primary user, organization, and bucket. -InfluxDB is now initialized with a primary user, organization, bucket, and authentication token. (For instructions on viewing your token via CLI or UI, see [View tokens](/v2.0/security/tokens/view-tokens/).) +InfluxDB is now initialized with a primary user, organization, bucket, and authentication token. + +To continue to use InfluxDB via the CLI, you need the authentication token created during setup. To view the token, log into the UI with the credentials created above. (For instructions, see [View tokens in the InfluxDB UI](/v2.0/security/tokens/view-tokens/#view-tokens-in-the-influxdb-ui).) + You are ready to [write or collect data](/v2.0/write-data). {{% note %}} From 28f3dfda8f46521656ba818cf36db54327c519b0 Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Wed, 20 May 2020 14:11:42 -0700 Subject: [PATCH 09/24] Remove credentials option, add info about `influx config create` --- content/v2.0/get-started.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index cdee2e640..23a982e69 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -385,14 +385,13 @@ To use the [`influx` CLI](/v2.0/reference/cli/influx) after setting up InfluxDB Use one of the following methods to provide your authentication token to the CLI: -1. Pass your token to the `influx` CLI using the `-t` or `--token` flag. -2. Set the `INFLUX_TOKEN` environment variable using your token. +- Create a new InfluxDB connection configuration using the [`influx config create` command](/v2.0/reference/cli/influx/config/create/). +- Pass your token to the `influx` CLI using the `-t` or `--token` flag. +- Set the `INFLUX_TOKEN` environment variable using your token. ```bash export INFLUX_TOKEN=oOooYourAuthTokenOoooOoOO== ``` -3. Store your token in `~/.influxdbv2/credentials`. - _The content of the `credentials` file should be only your token._ _See [View tokens](/v2.0/security/tokens/view-tokens/) for information about retrieving authentication tokens._ @@ -421,7 +420,7 @@ influx setup InfluxDB is now initialized with a primary user, organization, bucket, and authentication token. -To continue to use InfluxDB via the CLI, you need the authentication token created during setup. To view the token, log into the UI with the credentials created above. (For instructions, see [View tokens in the InfluxDB UI](/v2.0/security/tokens/view-tokens/#view-tokens-in-the-influxdb-ui).) +To continue to use InfluxDB via the CLI, you need the authentication token created during setup. To view the token, log into the UI with the credentials created above. (For instructions, see [View tokens in the InfluxDB UI](/v2.0/security/tokens/view-tokens/#view-tokens-in-the-influxdb-ui).) You are ready to [write or collect data](/v2.0/write-data). From 5b52335bc2662f9300071a7af537a035a4acadfe Mon Sep 17 00:00:00 2001 From: Russ Savage Date: Thu, 21 May 2020 10:53:57 -0700 Subject: [PATCH 10/24] fix(getting-started): minor edits --- content/v2.0/get-started.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index 23a982e69..8212ca83b 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -418,7 +418,7 @@ influx setup Enter nothing for an infinite retention period. 7. Confirm the details for your primary user, organization, and bucket. -InfluxDB is now initialized with a primary user, organization, bucket, and authentication token. +InfluxDB is now initialized with a primary user, organization, bucket, and authentication token. It has also create a config profile for you so that you don't have to add organization and token to every command. To view that config profile, use the [`influx config list`](/v2.0/reference/cli/influx/config) command. To continue to use InfluxDB via the CLI, you need the authentication token created during setup. To view the token, log into the UI with the credentials created above. (For instructions, see [View tokens in the InfluxDB UI](/v2.0/security/tokens/view-tokens/#view-tokens-in-the-influxdb-ui).) @@ -488,9 +488,6 @@ The primary differences between InfluxDB OSS 2.0 and InfluxDB Cloud 2.0 are: - [InfluxDB scrapers](/v2.0/write-data/scrape-data/) that collect data from specified targets are not available in {{< cloud-name "short" >}}. - {{< cloud-name "short" >}} instances are currently limited to a single organization with a single user. -- **InfluxDB Cloud** does not support retrieving data from a file based CSV source - using the `file` parameter of the [`csv.from()`](/v2.0/reference/flux/functions/csv/from); - however you can use raw CSV data with the `csv` parameter. #### New features in InfluxDB Cloud 2.0 From 682368269a8516f7e8db282b2f52ef9c755888e1 Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Fri, 22 May 2020 07:02:10 +0200 Subject: [PATCH 11/24] docs: add link to Kotlin and Scala library --- .../v2.0/reference/api/client-libraries/kotlin.md | 12 ++++++++++++ content/v2.0/reference/api/client-libraries/scala.md | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 content/v2.0/reference/api/client-libraries/kotlin.md create mode 100644 content/v2.0/reference/api/client-libraries/scala.md diff --git a/content/v2.0/reference/api/client-libraries/kotlin.md b/content/v2.0/reference/api/client-libraries/kotlin.md new file mode 100644 index 000000000..ad3d976ad --- /dev/null +++ b/content/v2.0/reference/api/client-libraries/kotlin.md @@ -0,0 +1,12 @@ +--- +title: InfluxDB Kotlin client library +list_title: Kotlin +description: Use the Kotlin client library to interact with InfluxDB. +external_url: https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin +menu: + v2_0_ref: + name: Kotlin + parent: Client libraries + url: https://github.com/influxdata/influxdb-client-java/tree/master/client-kotlin +weight: 201 +--- diff --git a/content/v2.0/reference/api/client-libraries/scala.md b/content/v2.0/reference/api/client-libraries/scala.md new file mode 100644 index 000000000..e7fecb067 --- /dev/null +++ b/content/v2.0/reference/api/client-libraries/scala.md @@ -0,0 +1,12 @@ +--- +title: InfluxDB Scala client library +list_title: Scala +description: Use the Scala client library to interact with InfluxDB. +external_url: https://github.com/influxdata/influxdb-client-java/tree/master/client-scala +menu: + v2_0_ref: + name: Scala + parent: Client libraries + url: https://github.com/influxdata/influxdb-client-java/tree/master/client-scala +weight: 201 +--- From 5aa622447e67c93ca73dba829b2a50572c2662b8 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 26 May 2020 15:27:50 -0600 Subject: [PATCH 12/24] updated v1 fieldkeys doc to address PR feedback --- content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md b/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md index 1f3cf1155..9d3b680e0 100644 --- a/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md +++ b/content/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys.md @@ -1,6 +1,6 @@ --- title: v1.fieldKeys() function -description: The `v1.fieldKeys()` function returns a list of fields in a bucket. +description: The `v1.fieldKeys()` function returns field keys in a bucket. menu: v2_0_ref: name: v1.fieldKeys @@ -12,7 +12,7 @@ related: - https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-field-keys, SHOW FIELD KEYS in InfluxQL --- -The `v1.fieldKeys()` function returns a list of fields in a bucket. +The `v1.fieldKeys()` function returns field keys in a bucket. The return value is always a single table with a single column, `_value`. ```js From a828d867b2a06e7f6f0c388d5efc2b365eaf7c3b Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Wed, 27 May 2020 08:39:47 -0700 Subject: [PATCH 13/24] Remove single user reference --- content/v2.0/get-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index 8212ca83b..0c38d0e10 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -487,7 +487,7 @@ The primary differences between InfluxDB OSS 2.0 and InfluxDB Cloud 2.0 are: - [InfluxDB scrapers](/v2.0/write-data/scrape-data/) that collect data from specified targets are not available in {{< cloud-name "short" >}}. -- {{< cloud-name "short" >}} instances are currently limited to a single organization with a single user. +- {{< cloud-name "short" >}} instances are currently limited to a single organization. #### New features in InfluxDB Cloud 2.0 From 62ef1eecd76bd6544c0db70d97bad38815ea2f0e Mon Sep 17 00:00:00 2001 From: pierwill Date: Tue, 26 May 2020 11:07:50 -0700 Subject: [PATCH 14/24] Update terminology in Cloud Multi-user docs Fixes #1066 --- .../account-management/multi-member/_index.md | 16 ----------- .../multi-member/invite-member.md | 28 ------------------- .../multi-member/remove-memberr.md | 16 ----------- .../account-management/multi-user/_index.md | 16 +++++++++++ .../multi-user/invite-user.md | 27 ++++++++++++++++++ .../multi-user/remove-user.md | 15 ++++++++++ 6 files changed, 58 insertions(+), 60 deletions(-) delete mode 100644 content/v2.0/account-management/multi-member/_index.md delete mode 100644 content/v2.0/account-management/multi-member/invite-member.md delete mode 100644 content/v2.0/account-management/multi-member/remove-memberr.md create mode 100644 content/v2.0/account-management/multi-user/_index.md create mode 100644 content/v2.0/account-management/multi-user/invite-user.md create mode 100644 content/v2.0/account-management/multi-user/remove-user.md diff --git a/content/v2.0/account-management/multi-member/_index.md b/content/v2.0/account-management/multi-member/_index.md deleted file mode 100644 index 83f3d33da..000000000 --- a/content/v2.0/account-management/multi-member/_index.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Manage multiple members -description: > - View and manage multiple members in an InfluxDB Cloud account. -weight: 4 -menu: - v2_0: - parent: Account management - name: Manage multiple members ---- - -{{< cloud-name >}} accounts support multiple members in an organization. -Collaborate with others using these features. -By default, each member has full permissions on resources in your organization. - -{{< children >}} diff --git a/content/v2.0/account-management/multi-member/invite-member.md b/content/v2.0/account-management/multi-member/invite-member.md deleted file mode 100644 index 7f1bf84d4..000000000 --- a/content/v2.0/account-management/multi-member/invite-member.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: Invite a member -list_title: Invite a member -description: > - Invite a member to collaborate in InfluxDB Cloud. -weight: 103 -menu: - v2_0: - parent: Manage multiple members - name: Invite a member ---- - -1. Navigate to the **Members** page under **Organizations** in the left navigation bar. - {{< nav-icon "org" >}} -2. Under **Add a new member to your organization**, enter the email address of the member to invite. - (Members must be invited one at a time.) -3. Click **Add & Invite**. - -An invitation with an activation link is sent to the specified email address. -The activation link expires after 72 hours. - -Once activated, the new member is added as an **Owner** with permissions to read and write all resources. - -{{% warn %}} -Currently, Cloud 2.0 has only one permission level: Owner. -With Owner permissions, a member can delete resources and other members from your organization. -Take care when inviting a member. -{{% /warn %}} diff --git a/content/v2.0/account-management/multi-member/remove-memberr.md b/content/v2.0/account-management/multi-member/remove-memberr.md deleted file mode 100644 index 614bebe14..000000000 --- a/content/v2.0/account-management/multi-member/remove-memberr.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Remove a member -seotitle: Remove a member from your InfluxDB Cloud organization -description: > - Remove a member from an InfluxDB Cloud organization. -weight: 103 -menu: - v2_0: - parent: Manage multiple members - identifier: remove_member_cloud ---- - -1. Navigate to the **Members** page under **Organizations** in the left navigation bar. - {{< nav-icon "org" >}} -2. Click the {{< icon "delete" >}} next to the member you want to remove. -3. Confirm the removal. diff --git a/content/v2.0/account-management/multi-user/_index.md b/content/v2.0/account-management/multi-user/_index.md new file mode 100644 index 000000000..365fe95fe --- /dev/null +++ b/content/v2.0/account-management/multi-user/_index.md @@ -0,0 +1,16 @@ +--- +title: Manage multiple users +description: > + View and manage multiple users in an InfluxDB Cloud account. +weight: 4 +menu: + v2_0: + parent: Account management + name: Manage multiple users +--- + +{{< cloud-name >}} accounts support multiple users in an organization. +Collaborate with others using these features. +By default, each user has full permissions on resources in your organization. + +{{< children >}} diff --git a/content/v2.0/account-management/multi-user/invite-user.md b/content/v2.0/account-management/multi-user/invite-user.md new file mode 100644 index 000000000..b3cfb526f --- /dev/null +++ b/content/v2.0/account-management/multi-user/invite-user.md @@ -0,0 +1,27 @@ +--- +title: Invite a user +list_title: Invite a user +description: > + Invite a user to collaborate in InfluxDB Cloud. +weight: 103 +menu: + v2_0: + parent: Manage multiple users + identifier: invite_user_cloud +--- + +1. Navigate to the **Users** page in the left navigation bar. +2. Under **Add a new user to your organization**, enter the email address of the user to invite. + (Users must be invited one at a time.) +3. Click **Add & Invite**. + +An invitation with an activation link is sent to the specified email address. +The activation link expires after 72 hours. + +Once activated, the new user is added as an **Owner** with permissions to read and write all resources. + +{{% warn %}} +Currently, Cloud 2.0 has only one permission level: Owner. +With Owner permissions, a user can delete resources and other users from your organization. +Take care when inviting a user. +{{% /warn %}} diff --git a/content/v2.0/account-management/multi-user/remove-user.md b/content/v2.0/account-management/multi-user/remove-user.md new file mode 100644 index 000000000..f00d2e034 --- /dev/null +++ b/content/v2.0/account-management/multi-user/remove-user.md @@ -0,0 +1,15 @@ +--- +title: Remove a user +seotitle: Remove a user from your InfluxDB Cloud organization +description: > + Remove a user from an InfluxDB Cloud organization. +weight: 103 +menu: + v2_0: + parent: Manage multiple users + identifier: remove_user_cloud +--- + +1. Navigate to the **Users** page in the left navigation bar. +2. Click the {{< icon "delete" >}} next to the user you want to remove. +3. Confirm the removal. From 7b8990dd887b76dceb9c4f6a8618c75591ba4bf4 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 28 May 2020 16:04:12 -0600 Subject: [PATCH 15/24] Flux 0.68 changelog --- content/v2.0/reference/release-notes/flux.md | 127 ++++++++++++++++++- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index da2c34673..b9cf597b8 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -16,6 +16,121 @@ Though newer versions of Flux may be available, they will not be included with InfluxDB until the next InfluxDB v2.0 release._ {{% /note %}} +## v0.68.0 [2020-05-28] +This version of Flux introduces an updated type inference system that improves +performance, error messaging, and usability of the +[Flux Language Server Protocol (LSP)](https://github.com/influxdata/flux-lsp). + +## Breaking Changes +- Change signature of `group()` function. + +## Features +- Add [`fieldKeys()`](/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys/) and + [`measurementFieldKeys()`](/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys/) + to v1 package. +- Add a context to `plantest.RuleTestCase`. +- Add Snowflake support to SQL package. +- Add `experimental.chain()` function. +- Add semantic nodes for bad statement and bad expression. +- Add [`findColumn()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/) + and [`findRecord()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/) functions. +- Return `false` if `contains()` is called with an empty set. +- Add small performance optimizations. +- Add a dynamically linked Valgrind test. +- Add location information to type error messages. +- Add all Linux cross-compilation tools to release Docker image. +- Support remote `buckets()` and `v1.databases()` calls. +- Add support for static linking. +- Add `influxdb` source. +- Add support for `pkg-config`. +- Transform semantic nodes back to AST nodes. +- Handle multi-file packages. +- Make `Eval()` and `EvalAST()` use libflux for parsing and analysis. +- Add `lookuptype` function for stdlib builtins. + +## Bug Fixes +- Reenable Clippy linter rule match single binding. +- Fix bug in object equal method. +- Add builtin formatting. +- Implement TimeBounds for `influxdb.fromRemote`. +- Inject the URL validator into `NewDefaultClient`. +- Fix race condition in the `filter()` function. +- Validate HTTP redirects against private IPs. +- Do not disclose DNS info in HTTP. +- Fix concurrent map write in `filter()` transformation. +- Copy all fields of `WindowProcedureSpec` in `Copy()`. +- Run `go generate` on libflux when `go generate` is run on stdlib. +- `map()` panics when overwriting group column. +- Support execution contexts in the REPL. +- Apply substitution fully when compiling lambda. +- Planner rewrite rules take a context. +- Functions do not panic on null values. +- Fixed logic for merging packages with no package clause. +- Compute function's return type after substitution. +- Resolve member expressions. +- More descriptive error messages. +- Check types of parts when evaluating `StringExpression`. +- Bind appropriate interpreter when evaluating functions. +- Tweak Rust JSON serialization and add tests. +- Pivot will send update watermark and processing time exactly once. +- Calculate diff's watermark using both predecessors. +- Add length check to avoid allocs checking for JSON `null`. +- Make compilers robust to `null` keyword in `extern` field. +- Address issues in `RemoveTrivialFilterRule`. +- Bind appropriate interpreter when evaluating functions. +- Convert `HashMap` in semantic package to `BTreeMap`. +- Use static linking when creating the Valgrind test. +- Update `flatbuffers` dependency. +- Fix JSON serialization of Rust AST. +- Remove unused environment variables. +- Make `merge_packages` allow no package clauses. +- Should not call `CheckKind` when evaluating logical expressions. +- Force the go libflux wrapper to rebuild using `go generate`. +- Adjust `test-bench` config for Circle CI. +- Fix Valgrind test code. +- Let Rust parser parse with file name. +- Remove Algorithm-W to-do list. +- `JoinStr` returns a string, not an empty record. +- Only add visible properties to output of `map()`. +- InfluxDB source would serialize the wrong sign duration literal. +- Remove code in semantic package that depends on Rust/Cgo code. +- Remove component field from API. +- Remove unused notification rule fields from Slack and PagerDuty APIs. +- Array builders must take array types as input. +- Un-skip `map()` tests with null values. +- Remove tests for marshalling semantic graph. +- Run `make generate`. +- Type error in benchmark test. +- Update `TableObject` test. +- Do not call `LocalRange` on nil scope. +- Type assertion error in `length()` tests. +- Update type inference test case with test for `union()`. +- Make non-test CI steps pass. +- Fix semantic check for option reassignment. +- Type inference tests for binary comparison operators. +- Fix typo in builtins. +- Update `holtWinters()` to make `seasonality` optional. +- Type errors in tests. +- Remove default value from notify data as it is required. +- Allow options to be set in scope. +- Replace `ScopeComparer` with `ScopeTransformer`. +- Use `LocalRange` in compile tests. +- Add missing parameter to type of `to()`. +- Get `TableObject` test case to compile. +- Typo in test case. +- Update `TableObjects` to type `Array`. +- Use array type method correctly. +- Schema mutators and miscellaneous to-do items. +- Return proper types for type conversion functions. +- Complete package compiles and passes tests. +- Make stdlib compile. +- Expect monotypes for function values. +- Require successful lookup of stdlib builtins or panic. +- Optimize lookup function using hashmap. +- Include function type when deserializing function expressions. + +--- + ## v0.67.0 [2020-04-28] ### Features @@ -193,7 +308,7 @@ InfluxDB until the next InfluxDB v2.0 release._ ## v0.59.0 [2020-01-14] ### Features -- Add Go/Rust API for getting semantic graph.. +- Add Go/Rust API for getting semantic graph. - Optimize `limit()` transformation. - Optimize `group()` transformation. @@ -251,7 +366,7 @@ InfluxDB until the next InfluxDB v2.0 release._ - Update `experimental.set` builtin type. - Update the type of `influxdb.to` to be a passthrough. - Update `fill` builtin type. -- Remove redundant clones found by a new version of clippy. +- Remove redundant clones found by a new version of Clippy. - Fix durations in Rust semantic graph. - Removes unnecessary rc clone in semantic serializer. - Do not stall forever in flux-config when an error happens with verbose. @@ -266,7 +381,7 @@ InfluxDB until the next InfluxDB v2.0 release._ ## v0.57.0 [2019-12-10] ### Features -- Categorize more flux errors with codes. +- Categorize more Flux errors with codes. - Teach flux-config how to download the sources when using vendor. - Opentracing in query execution runtime. - Reduce memory allocations for operations in values. @@ -292,7 +407,7 @@ InfluxDB until the next InfluxDB v2.0 release._ ### Bug fixes - Properly use a fake version with `flux-config` when no version is present. -- Address clippy lints. +- Address Clippy lints. - Add bytes monotype to Rust semantic module. - Allow underscores (`_`) in type expressions. @@ -408,7 +523,7 @@ InfluxDB until the next InfluxDB v2.0 release._ - Update libflux parser to match the Go parser. - Allow data collected by `prometheus.scrape()` to be used by `histogramQuantile()`. - Remove mock allocator. -- Validate url for `sql.from()`, `sql.to()`, and `socket.from()`. +- Validate URL for `sql.from()`, `sql.to()`, and `socket.from()`. --- @@ -1212,7 +1327,7 @@ In Flux 0.39.0, `holtWinters()` can cause the query engine to panic. - Implement and require builtin statements. - Fix keys to output group key. - Organizes builtin code into Flux packages. -- Change flux command to be a REPL. +`- Change flux command to be a REPL.` ### Features - Implement and require builtin statements. From 0d4b89c48ccde6c3149dde3167852522a99b2603 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 29 May 2020 08:48:46 -0600 Subject: [PATCH 16/24] updates to flux 0.68 changelog to address PR review --- content/v2.0/reference/release-notes/flux.md | 46 ++++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index b9cf597b8..3aea1d141 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -35,7 +35,7 @@ performance, error messaging, and usability of the - Add [`findColumn()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/) and [`findRecord()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/) functions. - Return `false` if `contains()` is called with an empty set. -- Add small performance optimizations. +- Various performance optimizations. - Add a dynamically linked Valgrind test. - Add location information to type error messages. - Add all Linux cross-compilation tools to release Docker image. @@ -49,30 +49,30 @@ performance, error messaging, and usability of the - Add `lookuptype` function for stdlib builtins. ## Bug Fixes -- Reenable Clippy linter rule match single binding. +- Re-enable Clippy linter rule match single binding. - Fix bug in object equal method. - Add builtin formatting. -- Implement TimeBounds for `influxdb.fromRemote`. +- Implement `TimeBounds` for `influxdb.fromRemote`. - Inject the URL validator into `NewDefaultClient`. - Fix race condition in the `filter()` function. - Validate HTTP redirects against private IPs. -- Do not disclose DNS info in HTTP. +- Hide DNS information in HTTP. - Fix concurrent map write in `filter()` transformation. - Copy all fields of `WindowProcedureSpec` in `Copy()`. - Run `go generate` on libflux when `go generate` is run on stdlib. -- `map()` panics when overwriting group column. +- Fix panic when `map()` overwrites group column. - Support execution contexts in the REPL. - Apply substitution fully when compiling lambda. - Planner rewrite rules take a context. -- Functions do not panic on null values. -- Fixed logic for merging packages with no package clause. +- Fix panics when functions operate on null values. +- Fix logic for merging packages with no package clause. - Compute function's return type after substitution. - Resolve member expressions. -- More descriptive error messages. +- Improve error message descriptions. - Check types of parts when evaluating `StringExpression`. - Bind appropriate interpreter when evaluating functions. - Tweak Rust JSON serialization and add tests. -- Pivot will send update watermark and processing time exactly once. +- Pivot sends update watermark and processing time exactly once. - Calculate diff's watermark using both predecessors. - Add length check to avoid allocs checking for JSON `null`. - Make compilers robust to `null` keyword in `extern` field. @@ -84,23 +84,23 @@ performance, error messaging, and usability of the - Fix JSON serialization of Rust AST. - Remove unused environment variables. - Make `merge_packages` allow no package clauses. -- Should not call `CheckKind` when evaluating logical expressions. -- Force the go libflux wrapper to rebuild using `go generate`. +- Do not call `CheckKind` when evaluating logical expressions. +- Force the Go libflux wrapper to rebuild using `go generate`. - Adjust `test-bench` config for Circle CI. - Fix Valgrind test code. - Let Rust parser parse with file name. - Remove Algorithm-W to-do list. - `JoinStr` returns a string, not an empty record. - Only add visible properties to output of `map()`. -- InfluxDB source would serialize the wrong sign duration literal. +- Serialize the correct sign duration literal. - Remove code in semantic package that depends on Rust/Cgo code. -- Remove component field from API. +- Remove `component` field from API. - Remove unused notification rule fields from Slack and PagerDuty APIs. -- Array builders must take array types as input. -- Un-skip `map()` tests with null values. +- Array builders accept array types as input. +- Enable `map()` tests with null values. - Remove tests for marshalling semantic graph. -- Run `make generate`. -- Type error in benchmark test. +- Run `make generate` to generate stdlib. +- Fix type error in benchmark test. - Update `TableObject` test. - Do not call `LocalRange` on nil scope. - Type assertion error in `length()` tests. @@ -110,19 +110,19 @@ performance, error messaging, and usability of the - Type inference tests for binary comparison operators. - Fix typo in builtins. - Update `holtWinters()` to make `seasonality` optional. -- Type errors in tests. -- Remove default value from notify data as it is required. +- Fix type errors in tests. +- Remove default value from notify data. - Allow options to be set in scope. - Replace `ScopeComparer` with `ScopeTransformer`. - Use `LocalRange` in compile tests. - Add missing parameter to type of `to()`. - Get `TableObject` test case to compile. -- Typo in test case. +- Fix typo in test case. - Update `TableObjects` to type `Array`. - Use array type method correctly. -- Schema mutators and miscellaneous to-do items. +- Update schema mutators. - Return proper types for type conversion functions. -- Complete package compiles and passes tests. +- Enable complete package to compile and pass tests. - Make stdlib compile. - Expect monotypes for function values. - Require successful lookup of stdlib builtins or panic. @@ -1327,7 +1327,7 @@ In Flux 0.39.0, `holtWinters()` can cause the query engine to panic. - Implement and require builtin statements. - Fix keys to output group key. - Organizes builtin code into Flux packages. -`- Change flux command to be a REPL.` +- Change flux command to be a REPL. ### Features - Implement and require builtin statements. From 79bf0855ad6f45255bd24ca96cd2cec80d831cfc Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 29 May 2020 09:18:28 -0600 Subject: [PATCH 17/24] added boilerplate for experimental.chain --- .../flux/stdlib/experimental/chain.md | 62 +++++++++++++++++++ content/v2.0/reference/release-notes/flux.md | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 content/v2.0/reference/flux/stdlib/experimental/chain.md diff --git a/content/v2.0/reference/flux/stdlib/experimental/chain.md b/content/v2.0/reference/flux/stdlib/experimental/chain.md new file mode 100644 index 000000000..fc677b5b5 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/chain.md @@ -0,0 +1,62 @@ +--- +title: experimental.chain() function +description: > + The `experimental.chain()` function ... +menu: + v2_0_ref: + name: experimental.chain + parent: Experimental +weight: 302 +--- + +The `experimental.chain()` function ... + +_**Function type:** miscellaneous_ + +```js +import "experimental" + +experimental.chain( + first: , + second: +) +``` + +{{% note %}} +The `experimental.chain()` function is only necessary in the following use cases: + +- ... +{{% /note %}} + + +## Parameters + +### first +... + +_**Data type:** Stream of tables_ + +### second +... + +_**Data type:** Stream of tables_ + +## Examples + +### ... +```js +import "experimental" + +table1 = from(bucket: "example-bucket") + |> range(start: -12mo) + |> filter(fn: (r) => r._measurement == "example-measurement1") + +table2 = from(bucket: "example-bucket") + |> range(start: -12mo) + |> filter(fn: (r) => r._measurement == "example-measurement2") + +experimental.chain( + first: table1, + second: table2 +) +``` diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index 3aea1d141..6780e4407 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -30,7 +30,7 @@ performance, error messaging, and usability of the to v1 package. - Add a context to `plantest.RuleTestCase`. - Add Snowflake support to SQL package. -- Add `experimental.chain()` function. +- Add [`experimental.chain()`](/v2.0/reference/flux/stdlib/experimental/chain/) function. - Add semantic nodes for bad statement and bad expression. - Add [`findColumn()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findcolumn/) and [`findRecord()`](/v2.0/reference/flux/stdlib/built-in/transformations/stream-table/findrecord/) functions. From accaf074ba1ef5d9bb6db84aa9a9e8cf7272d279 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 29 May 2020 11:14:22 -0600 Subject: [PATCH 18/24] added experimental.chain function --- .../flux/stdlib/experimental/chain.md | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/chain.md b/content/v2.0/reference/flux/stdlib/experimental/chain.md index fc677b5b5..85f7423d4 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/chain.md +++ b/content/v2.0/reference/flux/stdlib/experimental/chain.md @@ -9,54 +9,59 @@ menu: weight: 302 --- -The `experimental.chain()` function ... +The `experimental.chain()` function forces two queries in a single Flux script +to run sequentially and outputs the results of the second query. +The Flux execution planner typically executes multiple queries in a single script in parallel. +Running the queries sequentially ensures any dependencies the second query has on +the results of the first query are met. -_**Function type:** miscellaneous_ +##### Applicable use cases: +- Writing to and bucket and querying the written data in a single Flux script or + [InfluxDB task](/v2.0/process-data/get-started/). +- Forcing the order of query execution in testing scenarios. + +_**Function type:** Miscellaneous_ ```js import "experimental" experimental.chain( - first: , - second: + first: query1, + second: query2 ) ``` -{{% note %}} -The `experimental.chain()` function is only necessary in the following use cases: - -- ... -{{% /note %}} - - ## Parameters ### first -... +The first query to execute. _**Data type:** Stream of tables_ ### second -... +The second query to execute. _**Data type:** Stream of tables_ ## Examples -### ... +### Write to a bucket and query the written data ```js import "experimental" -table1 = from(bucket: "example-bucket") - |> range(start: -12mo) - |> filter(fn: (r) => r._measurement == "example-measurement1") +downsampled_max = from(bucket: "example-bucket-1") + |> range(start: -1d) + |> filter(fn: (r) => r._measurement == "example-measurement") + |> aggregateWindow(every: 1h, fn: max) + |> to(bucket: "downsample-1h-max", org: "example-org") -table2 = from(bucket: "example-bucket") - |> range(start: -12mo) - |> filter(fn: (r) => r._measurement == "example-measurement2") +average_max = from(bucket: "downsample-1h-max") + |> range(start: -1d) + |> filter(fn: (r) => r.measurement == "example-measurement") + |> mean() experimental.chain( - first: table1, - second: table2 + first: downsampled_max, + second: average_max ) ``` From 891296f688420f43c66cb1cb2c09470bd88b721e Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 29 May 2020 14:32:40 -0600 Subject: [PATCH 19/24] updates to experimental.chain to address PR feedback --- .../reference/flux/stdlib/experimental/chain.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/chain.md b/content/v2.0/reference/flux/stdlib/experimental/chain.md index 85f7423d4..8f7868231 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/chain.md +++ b/content/v2.0/reference/flux/stdlib/experimental/chain.md @@ -1,7 +1,8 @@ --- title: experimental.chain() function description: > - The `experimental.chain()` function ... + The `experimental.chain()` function runs two queries in a single Flux script + sequentially and outputs the results of the second query. menu: v2_0_ref: name: experimental.chain @@ -9,16 +10,16 @@ menu: weight: 302 --- -The `experimental.chain()` function forces two queries in a single Flux script -to run sequentially and outputs the results of the second query. -The Flux execution planner typically executes multiple queries in a single script in parallel. +The `experimental.chain()` function runs two queries in a single Flux script +sequentially and outputs the results of the second query. +Flux typically executes multiple queries in a single script in parallel. Running the queries sequentially ensures any dependencies the second query has on the results of the first query are met. -##### Applicable use cases: -- Writing to and bucket and querying the written data in a single Flux script or +##### Applicable use cases +- Writing to a bucket and querying the written data in a single Flux script or [InfluxDB task](/v2.0/process-data/get-started/). -- Forcing the order of query execution in testing scenarios. +- Execute queries sequentially in testing scenarios. _**Function type:** Miscellaneous_ From c0f484865204e0c83243ab37cd2d7639e2023cbd Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Mon, 1 Jun 2020 11:57:24 -0700 Subject: [PATCH 20/24] Add location column to URL tables (addresses #1077 ) --- data/influxdb_urls.yml | 8 ++++++-- layouts/shortcodes/cloud_regions.html | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/data/influxdb_urls.yml b/data/influxdb_urls.yml index cbe01e84a..a8a5d376f 100644 --- a/data/influxdb_urls.yml +++ b/data/influxdb_urls.yml @@ -12,18 +12,22 @@ cloud: - name: Amazon Web Services short_name: AWS regions: - - name: US West (Oregon) + - name: US West + location: Oregon, USA url: https://us-west-2-1.aws.cloud2.influxdata.com - name: EU Frankfurt + location: Frankfurt, Germany url: https://eu-central-1-1.aws.cloud2.influxdata.com - name: Google Cloud Platform short_name: GCP regions: - - name: US Central (Iowa) + - name: US Central + location: Iowa, USA url: https://us-central1-1.gcp.cloud2.influxdata.com - name: Microsoft Azure short_name: Azure regions: - name: West Europe + location: Amsterdam, Netherlands url: https://westeurope-1.azure.cloud2.influxdata.com status: beta diff --git a/layouts/shortcodes/cloud_regions.html b/layouts/shortcodes/cloud_regions.html index 46c0ecf19..4c23776e2 100644 --- a/layouts/shortcodes/cloud_regions.html +++ b/layouts/shortcodes/cloud_regions.html @@ -13,12 +13,14 @@ + {{ range .regions }} + {{ end }}
RegionLocation URL
{{ .name }} {{ .url }}{{ .location }}
From c44f4690c414728500b3d13c4cbed335b49bb3d5 Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Mon, 1 Jun 2020 12:02:39 -0700 Subject: [PATCH 21/24] Fix order of tds --- layouts/shortcodes/cloud_regions.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/cloud_regions.html b/layouts/shortcodes/cloud_regions.html index 4c23776e2..944247c6b 100644 --- a/layouts/shortcodes/cloud_regions.html +++ b/layouts/shortcodes/cloud_regions.html @@ -19,8 +19,8 @@ {{ range .regions }} {{ .name }} - {{ .url }} {{ .location }} + {{ .url }} {{ end }} From 566e261584206d64ecfbdf96c77373244edddae3 Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:42:32 -0700 Subject: [PATCH 22/24] Respond to PR feedback --- data/influxdb_urls.yml | 4 ++-- layouts/shortcodes/cloud_regions.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/influxdb_urls.yml b/data/influxdb_urls.yml index a8a5d376f..202b9fd73 100644 --- a/data/influxdb_urls.yml +++ b/data/influxdb_urls.yml @@ -12,7 +12,7 @@ cloud: - name: Amazon Web Services short_name: AWS regions: - - name: US West + - name: US West (Oregon) location: Oregon, USA url: https://us-west-2-1.aws.cloud2.influxdata.com - name: EU Frankfurt @@ -21,7 +21,7 @@ cloud: - name: Google Cloud Platform short_name: GCP regions: - - name: US Central + - name: US Central (Iowa) location: Iowa, USA url: https://us-central1-1.gcp.cloud2.influxdata.com - name: Microsoft Azure diff --git a/layouts/shortcodes/cloud_regions.html b/layouts/shortcodes/cloud_regions.html index 944247c6b..810201608 100644 --- a/layouts/shortcodes/cloud_regions.html +++ b/layouts/shortcodes/cloud_regions.html @@ -19,7 +19,7 @@ {{ range .regions }} {{ .name }} - {{ .location }} + <{{ .location }} {{ .url }} {{ end }} From 8c524a3624144f27e629342bd8e4e3f196c055b3 Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Thu, 4 Jun 2020 10:34:25 -0700 Subject: [PATCH 23/24] Update cloud_regions.html Fix typo --- layouts/shortcodes/cloud_regions.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/cloud_regions.html b/layouts/shortcodes/cloud_regions.html index 810201608..67798483d 100644 --- a/layouts/shortcodes/cloud_regions.html +++ b/layouts/shortcodes/cloud_regions.html @@ -19,7 +19,7 @@ {{ range .regions }} {{ .name }} - <{{ .location }} + {{ .location }} {{ .url }} {{ end }} From be21a2b69a5e4b8c5b96022a2bb5c2fd4b22fed3 Mon Sep 17 00:00:00 2001 From: noramullen1 <42354779+noramullen1@users.noreply.github.com> Date: Thu, 4 Jun 2020 10:35:50 -0700 Subject: [PATCH 24/24] Update cloud_regions.html Fix typo --- layouts/shortcodes/cloud_regions.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/cloud_regions.html b/layouts/shortcodes/cloud_regions.html index 810201608..67798483d 100644 --- a/layouts/shortcodes/cloud_regions.html +++ b/layouts/shortcodes/cloud_regions.html @@ -19,7 +19,7 @@ {{ range .regions }} {{ .name }} - <{{ .location }} + {{ .location }} {{ .url }} {{ end }}