updated use of object to record, updated flux lang links
parent
b69cdeed9a
commit
1766d66be4
|
@ -36,8 +36,8 @@ Flux will not query the database without a specified range.
|
|||
Use the pipe-forward operator (`|>`) to pipe data from your data source into the [`range()`](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/range)
|
||||
function, which specifies a time range for your query.
|
||||
It accepts two properties: `start` and `stop`.
|
||||
Ranges can be **relative** using negative [durations](/flux/v0.65/language/lexical-elements#duration-literals)
|
||||
or **absolute** using [timestamps](/flux/v0.65/language/lexical-elements#date-and-time-literals).
|
||||
Ranges can be **relative** using negative [durations](/{{< latest "influxdb" "v2" >}}/reference/flux/language/lexical-elements#duration-literals)
|
||||
or **absolute** using [timestamps](/{{< latest "influxdb" "v2" >}}/reference/flux/language/lexical-elements#date-and-time-literals).
|
||||
|
||||
###### Example relative time ranges
|
||||
```js
|
||||
|
@ -72,13 +72,13 @@ The `filter()` function has one parameter, `fn`, which expects an anonymous func
|
|||
with logic that filters data based on columns or attributes.
|
||||
|
||||
Flux's anonymous function syntax is very similar to Javascript's.
|
||||
Records or rows are passed into the `filter()` function as an object (`r`).
|
||||
The anonymous function takes the object and evaluates it to see if it matches the defined filters.
|
||||
Records or rows are passed into the `filter()` function as an record (`r`).
|
||||
The anonymous function takes the record and evaluates it to see if it matches the defined filters.
|
||||
Use the `AND` relational operator to chain multiple filters.
|
||||
|
||||
```js
|
||||
// Pattern
|
||||
(r) => (r.objectProperty comparisonOperator comparisonExpression)
|
||||
(r) => (r.recordProperty comparisonOperator comparisonExpression)
|
||||
|
||||
// Example with single filter
|
||||
(r) => (r._measurement == "cpu")
|
||||
|
|
|
@ -64,35 +64,35 @@ this is a string
|
|||
2
|
||||
```
|
||||
|
||||
### Objects
|
||||
Flux also supports objects. Each value in an object can be a different data type.
|
||||
### Records
|
||||
Flux also supports records. Each value in an record can be a different data type.
|
||||
|
||||
```js
|
||||
> o = {name:"Jim", age: 42, "favorite color": "red"}
|
||||
> rec = {name:"Jim", age: 42, "favorite color": "red"}
|
||||
```
|
||||
|
||||
Use **dot notation** to access a properties of an object:
|
||||
Use **dot notation** to access a properties of an record:
|
||||
|
||||
```js
|
||||
> o.name
|
||||
> rec.name
|
||||
Jim
|
||||
> o.age
|
||||
> rec.age
|
||||
42
|
||||
```
|
||||
|
||||
Or **bracket notation**:
|
||||
|
||||
```js
|
||||
> o["name"]
|
||||
> rec["name"]
|
||||
Jim
|
||||
> o["age"]
|
||||
> rec["age"]
|
||||
42
|
||||
> o["favorite color"]
|
||||
> rec["favorite color"]
|
||||
red
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
Use bracket notation to reference object properties with special or
|
||||
Use bracket notation to reference record properties with special or
|
||||
white space characters in the property key.
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ Use the `every` parameter to define a duration of time for each window.
|
|||
|
||||
{{% note %}}
|
||||
#### Calendar months and years
|
||||
`every` supports all [valid duration units](/flux/v0.65/language/types/#duration-types),
|
||||
`every` supports all [valid duration units](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#duration-types),
|
||||
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ title: Check if a value exists
|
|||
seotitle: Use Flux to check if a value exists
|
||||
list_title: Exists
|
||||
description: >
|
||||
Use the Flux `exists` operator to check if an object contains a key or if that
|
||||
Use the Flux `exists` operator to check if a record contains a key or if that
|
||||
key's value is `null`.
|
||||
menu:
|
||||
influxdb_1_7:
|
||||
|
@ -18,7 +18,7 @@ list_code_example: |
|
|||
```
|
||||
---
|
||||
|
||||
Use the Flux `exists` operator to check if an object contains a key or if that
|
||||
Use the Flux `exists` operator to check if a record contains a key or if that
|
||||
key's value is `null`.
|
||||
|
||||
```js
|
||||
|
|
|
@ -76,7 +76,7 @@ data
|
|||
|
||||
## Fill with a specified value
|
||||
To fill _null_ values with a specified value, use the `value` parameter to specify the fill value.
|
||||
_The fill value must match the [data type](/flux/v0.65/language/types/#basic-types)
|
||||
_The fill value must match the [data type](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#basic-types)
|
||||
of the [column](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/fill/#column)._
|
||||
|
||||
```js
|
||||
|
|
|
@ -52,7 +52,7 @@ uint(v: 2019-09-18T12:00:00.000000000Z)
|
|||
```
|
||||
|
||||
## Calculate the duration between two timestamps
|
||||
Flux doesn't support mathematical operations using [time type](/flux/v0.65/language/types/#time-types) values.
|
||||
Flux doesn't support mathematical operations using [time type](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#time-types) values.
|
||||
To calculate the duration between two timestamps:
|
||||
|
||||
1. Use the `uint()` function to convert each timestamp to a Unix nanosecond timestamp.
|
||||
|
|
|
@ -13,7 +13,7 @@ list_query_example: map_math
|
|||
---
|
||||
|
||||
Flux supports mathematic expressions in data transformations.
|
||||
This article describes how to use [Flux arithmetic operators](/flux/v0.65/language/operators/#arithmetic-operators)
|
||||
This article describes how to use [Flux arithmetic operators](/{{< latest "influxdb" "v2" >}}/reference/flux/language/operators/#arithmetic-operators)
|
||||
to "map" over data and transform values using mathematic operations.
|
||||
|
||||
If you're just getting started with Flux queries, check out the following:
|
||||
|
|
|
@ -40,13 +40,13 @@ Rows that evaluate to `false` are **excluded** from the output data.
|
|||
|
||||
The `fn` predicate function requires an `r` argument, which represents each row
|
||||
as `filter()` iterates over input data.
|
||||
Key-value pairs in the row object represent columns and their values.
|
||||
Key-value pairs in the row record represent columns and their values.
|
||||
Use **dot notation** or **bracket notation** to reference specific column values in the predicate function.
|
||||
Use [logical operators](/flux/v0.65/language/operators/#logical-operators)
|
||||
Use [logical operators](/{{< latest "influxdb" "v2" >}}/reference/flux/language/operators/#logical-operators)
|
||||
to chain multiple predicate expressions together.
|
||||
|
||||
```js
|
||||
// Row object
|
||||
// Row record
|
||||
r = {foo: "bar", baz: "quz"}
|
||||
|
||||
// Example predicate function
|
||||
|
|
|
@ -33,7 +33,7 @@ data
|
|||
```
|
||||
|
||||
By default, `derivative()` returns only positive derivative values and replaces negative values with _null_.
|
||||
Cacluated values are returned as [floats](/flux/v0.65/language/types/#numeric-types).
|
||||
Cacluated values are returned as [floats](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#numeric-types).
|
||||
|
||||
|
||||
{{< flex >}}
|
||||
|
|
|
@ -57,7 +57,7 @@ You still must extract that table from the stream.
|
|||
Use [`tableFind()`](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/)
|
||||
to extract the **first** table whose [group key](/influxdb/v1.7/flux/get-started/#group-keys)
|
||||
values match the `fn` **predicate function**.
|
||||
The predicate function requires a `key` object, which represents the group key of
|
||||
The predicate function requires a `key` record, which represents the group key of
|
||||
each table.
|
||||
|
||||
```js
|
||||
|
@ -130,7 +130,7 @@ SFOTemps[2]
|
|||
Use the [`getRecord()` function](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/)
|
||||
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.
|
||||
The function outputs a record with key-value pairs for each column.
|
||||
|
||||
```js
|
||||
sampleData
|
||||
|
@ -148,10 +148,10 @@ sampleData
|
|||
// }
|
||||
```
|
||||
|
||||
### Use an extracted row object
|
||||
Use a variable to store the extracted row object.
|
||||
### Use an extracted row record
|
||||
Use a variable to store the extracted row record.
|
||||
In the example below, `tempInfo` represents the extracted row.
|
||||
Use [dot notation](/influxdb/v1.7/flux/get-started/syntax-basics/#objects) to reference
|
||||
Use [dot notation](/influxdb/v1.7/flux/get-started/syntax-basics/#records) to reference
|
||||
keys in the object.
|
||||
|
||||
```js
|
||||
|
@ -202,7 +202,7 @@ lastJFKTemp
|
|||
|
||||
##### Extract scalar row data
|
||||
```js
|
||||
// Define a helper function to extract a row as an object
|
||||
// Define a helper function to extract a row as a record
|
||||
getRow = (tables=<-, field, idx=0) => {
|
||||
extract = tables
|
||||
|> tableFind(fn: (key) => true)
|
||||
|
|
|
@ -105,7 +105,7 @@ dataSet
|
|||
```
|
||||
|
||||
{{% note %}}
|
||||
The `every` parameter supports all [valid duration units](/flux/v0.65/language/types/#duration-types),
|
||||
The `every` parameter supports all [valid duration units](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#duration-types),
|
||||
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ Flux will not query the database without a specified range.
|
|||
Use the pipe-forward operator (`|>`) to pipe data from your data source into the [`range()`](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/range)
|
||||
function, which specifies a time range for your query.
|
||||
It accepts two properties: `start` and `stop`.
|
||||
Ranges can be **relative** using negative [durations](/flux/v0.65/language/lexical-elements#duration-literals)
|
||||
or **absolute** using [timestamps](/flux/v0.65/language/lexical-elements#date-and-time-literals).
|
||||
Ranges can be **relative** using negative [durations](/{{< latest "influxdb" "v2" >}}/reference/flux/language/lexical-elements#duration-literals)
|
||||
or **absolute** using [timestamps](/{{< latest "influxdb" "v2" >}}/reference/flux/language/lexical-elements#date-and-time-literals).
|
||||
|
||||
###### Example relative time ranges
|
||||
```js
|
||||
|
@ -72,13 +72,13 @@ The `filter()` function has one parameter, `fn`, which expects an anonymous func
|
|||
with logic that filters data based on columns or attributes.
|
||||
|
||||
Flux's anonymous function syntax is very similar to Javascript's.
|
||||
Records or rows are passed into the `filter()` function as an object (`r`).
|
||||
The anonymous function takes the object and evaluates it to see if it matches the defined filters.
|
||||
Records or rows are passed into the `filter()` function as a record (`r`).
|
||||
The anonymous function takes the record and evaluates it to see if it matches the defined filters.
|
||||
Use the `AND` relational operator to chain multiple filters.
|
||||
|
||||
```js
|
||||
// Pattern
|
||||
(r) => (r.objectProperty comparisonOperator comparisonExpression)
|
||||
(r) => (r.recordProperty comparisonOperator comparisonExpression)
|
||||
|
||||
// Example with single filter
|
||||
(r) => (r._measurement == "cpu")
|
||||
|
|
|
@ -64,14 +64,14 @@ this is a string
|
|||
2
|
||||
```
|
||||
|
||||
### Objects
|
||||
Flux also supports objects. Each value in an object can be a different data type.
|
||||
### Records
|
||||
Flux also supports records. Each value in a record can be a different data type.
|
||||
|
||||
```js
|
||||
> o = {name:"Jim", age: 42, "favorite color": "red"}
|
||||
```
|
||||
|
||||
Use **dot notation** to access a properties of an object:
|
||||
Use **dot notation** to access a properties of a record:
|
||||
|
||||
```js
|
||||
> o.name
|
||||
|
@ -92,7 +92,7 @@ red
|
|||
```
|
||||
|
||||
{{% note %}}
|
||||
Use bracket notation to reference object properties with special or
|
||||
Use bracket notation to reference record properties with special or
|
||||
white space characters in the property key.
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ Use the `every` parameter to define a duration of time for each window.
|
|||
|
||||
{{% note %}}
|
||||
#### Calendar months and years
|
||||
`every` supports all [valid duration units](/flux/v0.65/language/types/#duration-types),
|
||||
`every` supports all [valid duration units](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#duration-types),
|
||||
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ title: Check if a value exists
|
|||
seotitle: Use Flux to check if a value exists
|
||||
list_title: Exists
|
||||
description: >
|
||||
Use the Flux `exists` operator to check if an object contains a key or if that
|
||||
Use the Flux `exists` operator to check if a record contains a key or if that
|
||||
key's value is `null`.
|
||||
menu:
|
||||
influxdb_1_8:
|
||||
|
@ -18,7 +18,7 @@ list_code_example: |
|
|||
```
|
||||
---
|
||||
|
||||
Use the Flux `exists` operator to check if an object contains a key or if that
|
||||
Use the Flux `exists` operator to check if a record contains a key or if that
|
||||
key's value is `null`.
|
||||
|
||||
```js
|
||||
|
|
|
@ -76,7 +76,7 @@ data
|
|||
|
||||
## Fill with a specified value
|
||||
To fill _null_ values with a specified value, use the `value` parameter to specify the fill value.
|
||||
_The fill value must match the [data type](/flux/v0.65/language/types/#basic-types)
|
||||
_The fill value must match the [data type](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#basic-types)
|
||||
of the [column](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/fill/#column)._
|
||||
|
||||
```js
|
||||
|
|
|
@ -50,7 +50,7 @@ Define a geographic region using one of the the following shapes:
|
|||
- [polygon](#polygon)
|
||||
|
||||
### box
|
||||
Define a box-shaped region by specifying an object containing the following properties:
|
||||
Define a box-shaped region by specifying a record containing the following properties:
|
||||
|
||||
- **minLat:** minimum latitude in decimal degrees (WGS 84) _(Float)_
|
||||
- **maxLat:** maximum latitude in decimal degrees (WGS 84) _(Float)_
|
||||
|
@ -68,7 +68,7 @@ Define a box-shaped region by specifying an object containing the following prop
|
|||
```
|
||||
|
||||
### circle
|
||||
Define a circular region by specifying an object containing the following properties:
|
||||
Define a circular region by specifying a record containing the following properties:
|
||||
|
||||
- **lat**: latitude of the circle center in decimal degrees (WGS 84) _(Float)_
|
||||
- **lon**: longitude of the circle center in decimal degrees (WGS 84) _(Float)_
|
||||
|
@ -84,12 +84,12 @@ Define a circular region by specifying an object containing the following proper
|
|||
```
|
||||
|
||||
### polygon
|
||||
Define a polygonal region with an object containing the latitude and longitude for
|
||||
Define a polygonal region with a record containing the latitude and longitude for
|
||||
each point in the polygon:
|
||||
|
||||
- **points**: points that define the custom polygon _(Array of objects)_
|
||||
- **points**: points that define the custom polygon _(Array of records)_
|
||||
|
||||
Define each point with an object containing the following properties:
|
||||
Define each point with a record containing the following properties:
|
||||
|
||||
- **lat**: latitude in decimal degrees (WGS 84) _(Float)_
|
||||
- **lon**: longitude in decimal degrees (WGS 84) _(Float)_
|
||||
|
|
|
@ -52,7 +52,7 @@ uint(v: 2019-09-18T12:00:00.000000000Z)
|
|||
```
|
||||
|
||||
## Calculate the duration between two timestamps
|
||||
Flux doesn't support mathematical operations using [time type](/flux/v0.65/language/types/#time-types) values.
|
||||
Flux doesn't support mathematical operations using [time type](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#time-types) values.
|
||||
To calculate the duration between two timestamps:
|
||||
|
||||
1. Use the `uint()` function to convert each timestamp to a Unix nanosecond timestamp.
|
||||
|
|
|
@ -13,7 +13,7 @@ list_query_example: map_math
|
|||
---
|
||||
|
||||
Flux supports mathematic expressions in data transformations.
|
||||
This article describes how to use [Flux arithmetic operators](/flux/v0.65/language/operators/#arithmetic-operators)
|
||||
This article describes how to use [Flux arithmetic operators](/{{< latest "influxdb" "v2" >}}/reference/flux/language/operators/#arithmetic-operators)
|
||||
to "map" over data and transform values using mathematic operations.
|
||||
|
||||
If you're just getting started with Flux queries, check out the following:
|
||||
|
|
|
@ -40,13 +40,13 @@ Rows that evaluate to `false` are **excluded** from the output data.
|
|||
|
||||
The `fn` predicate function requires an `r` argument, which represents each row
|
||||
as `filter()` iterates over input data.
|
||||
Key-value pairs in the row object represent columns and their values.
|
||||
Key-value pairs in the row record represent columns and their values.
|
||||
Use **dot notation** or **bracket notation** to reference specific column values in the predicate function.
|
||||
Use [logical operators](/flux/v0.65/language/operators/#logical-operators)
|
||||
Use [logical operators](/{{< latest "influxdb" "v2" >}}/reference/flux/language/operators/#logical-operators)
|
||||
to chain multiple predicate expressions together.
|
||||
|
||||
```js
|
||||
// Row object
|
||||
// Row record
|
||||
r = {foo: "bar", baz: "quz"}
|
||||
|
||||
// Example predicate function
|
||||
|
|
|
@ -36,7 +36,7 @@ data
|
|||
```
|
||||
|
||||
By default, `derivative()` returns only positive derivative values and replaces negative values with _null_.
|
||||
Cacluated values are returned as [floats](/flux/v0.65/language/types/#numeric-types).
|
||||
Cacluated values are returned as [floats](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#numeric-types).
|
||||
|
||||
|
||||
{{< flex >}}
|
||||
|
@ -127,7 +127,7 @@ data
|
|||
)
|
||||
```
|
||||
|
||||
`aggregate.rate()` returns the average rate of change (as a [float](/flux/v0.65/language/types/#numeric-types))
|
||||
`aggregate.rate()` returns the average rate of change (as a [float](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#numeric-types))
|
||||
per `unit` for time intervals defined by `every`.
|
||||
Negative values are replaced with _null_.
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ You still must extract that table from the stream.
|
|||
Use [`tableFind()`](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/stream-table/tablefind/)
|
||||
to extract the **first** table whose [group key](/influxdb/v1.8/flux/get-started/#group-keys)
|
||||
values match the `fn` **predicate function**.
|
||||
The predicate function requires a `key` object, which represents the group key of
|
||||
The predicate function requires a `key` record, which represents the group key of
|
||||
each table.
|
||||
|
||||
```js
|
||||
|
@ -130,7 +130,7 @@ SFOTemps[2]
|
|||
Use the [`getRecord()` function](/{{< latest "influxdb" "v2" >}}/reference/flux/stdlib/built-in/transformations/stream-table/getrecord/)
|
||||
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.
|
||||
The function outputs a record with key-value pairs for each column.
|
||||
|
||||
```js
|
||||
sampleData
|
||||
|
@ -148,11 +148,11 @@ sampleData
|
|||
// }
|
||||
```
|
||||
|
||||
### Use an extracted row object
|
||||
Use a variable to store the extracted row object.
|
||||
### Use an extracted row record
|
||||
Use a variable to store the extracted row record.
|
||||
In the example below, `tempInfo` represents the extracted row.
|
||||
Use [dot notation](/influxdb/v1.8/flux/get-started/syntax-basics/#objects) to reference
|
||||
keys in the object.
|
||||
Use [dot notation](/influxdb/v1.8/flux/get-started/syntax-basics/#records) to reference
|
||||
keys in the record.
|
||||
|
||||
```js
|
||||
tempInfo = sampleData
|
||||
|
@ -202,7 +202,7 @@ lastJFKTemp
|
|||
|
||||
##### Extract scalar row data
|
||||
```js
|
||||
// Define a helper function to extract a row as an object
|
||||
// Define a helper function to extract a row as a record
|
||||
getRow = (tables=<-, field, idx=0) => {
|
||||
extract = tables
|
||||
|> tableFind(fn: (key) => true)
|
||||
|
|
|
@ -105,7 +105,7 @@ dataSet
|
|||
```
|
||||
|
||||
{{% note %}}
|
||||
The `every` parameter supports all [valid duration units](/flux/v0.65/language/types/#duration-types),
|
||||
The `every` parameter supports all [valid duration units](/{{< latest "influxdb" "v2" >}}/reference/flux/language/types/#duration-types),
|
||||
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||
{{% /note %}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue