commit
ede67b4040
|
@ -3,7 +3,7 @@ title: Calculate the increase
|
|||
seotitle: Calculate the increase in Flux
|
||||
list_title: Increase
|
||||
description: >
|
||||
Use the [`increase()` function](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase/)
|
||||
Use the [`increase()` function](/v2.0/reference/flux/stdlib/built-in/transformations/increase/)
|
||||
to track increases across multiple columns in a table.
|
||||
This function is especially useful when tracking changes in counter values that
|
||||
wrap over time or periodically reset.
|
||||
|
@ -18,7 +18,7 @@ related:
|
|||
list_query_example: increase
|
||||
---
|
||||
|
||||
Use the [`increase()` function](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase/)
|
||||
Use the [`increase()` function](/v2.0/reference/flux/stdlib/built-in/transformations/increase/)
|
||||
to track increases across multiple columns in a table.
|
||||
This function is especially useful when tracking changes in counter values that
|
||||
wrap over time or periodically reset.
|
||||
|
|
|
@ -16,7 +16,7 @@ menu:
|
|||
name: Rate
|
||||
v2.0/tags: [query, rate]
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/derivative/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/derivative/
|
||||
- /v2.0/reference/flux/stdlib/experimental/aggregate/rate/
|
||||
list_query_example: rate_of_change
|
||||
---
|
||||
|
|
|
@ -4,7 +4,8 @@ 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, MySQL, Snowflake, and SQLite.
|
||||
Use `sql.from()` to query SQL databases like PostgreSQL, MySQL, Snowflake,
|
||||
SQLite, Microsoft SQL Server, and Amazon Athena.
|
||||
v2.0/tags: [query, flux, sql]
|
||||
menu:
|
||||
v2_0:
|
||||
|
@ -30,8 +31,10 @@ 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/),
|
||||
[Snowflake](https://www.snowflake.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/), [SQLite](https://www.sqlite.org/index.html),
|
||||
[Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx),
|
||||
and [Amazon Athena](https://aws.amazon.com/athena/) 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)
|
||||
|
@ -57,6 +60,7 @@ To query a SQL data source:
|
|||
[MySQL](#)
|
||||
[Snowflake](#)
|
||||
[SQLite](#)
|
||||
[SQL Server](#)
|
||||
{{% /code-tabs %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
|
@ -110,6 +114,21 @@ sql.from(
|
|||
)
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```js
|
||||
import "sql"
|
||||
|
||||
sql.from(
|
||||
driverName: "sqlserver",
|
||||
dataSourceName: "sqlserver://user:password@localhost:1234?database=examplebdb",
|
||||
query: "GO SELECT * FROM Example.Table"
|
||||
)
|
||||
```
|
||||
|
||||
_For information about authenticating with SQL Server using ADO-style parameters,
|
||||
see [SQL Server ADO authentication](/v2.0/reference/flux/stdlib/sql/from/#sql-server-ado-authentication)._
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
_See the [`sql.from()` documentation](/v2.0/reference/flux/stdlib/sql/from/) for
|
||||
|
|
|
@ -12,7 +12,7 @@ related:
|
|||
- /v2.0/reference/flux/stdlib/system/time/
|
||||
---
|
||||
|
||||
The `now()` function returns the current time (UTC).
|
||||
The `now()` function returns the current time (UTC) or the time defined in the `now` option.
|
||||
|
||||
_**Function type:** Date/Time_
|
||||
_**Output data type:** Time_
|
||||
|
@ -22,11 +22,21 @@ now()
|
|||
```
|
||||
|
||||
## Examples
|
||||
|
||||
##### Use the current UTC time as a query boundary
|
||||
```js
|
||||
data
|
||||
|> range(start: -10h, stop: now())
|
||||
```
|
||||
|
||||
##### Return the now option time
|
||||
```js
|
||||
option now = () => 2020-01-01T00:00:00Z
|
||||
|
||||
now()
|
||||
// Returns 2020-01-01T00:00:00.000000000Z
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### now() vs system.time()
|
||||
`now()` returns the current UTC time.
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
---
|
||||
title: Flux built-in aggregate functions
|
||||
list_title: Built-in aggregate functions
|
||||
description: Flux's built-in aggregate functions take values from an input table and aggregate them in some way.
|
||||
title: Flux built-in aggregate transformations
|
||||
list_title: Built-in aggregate transformations
|
||||
description: >
|
||||
Flux's aggregate transformations take values from an input table and aggregate them in some way.
|
||||
Output tables contain a single row with the aggregated value.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/transformations/aggregates
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/
|
||||
|
@ -16,8 +18,8 @@ related:
|
|||
- /v2.0/query-data/flux/window-aggregate/
|
||||
---
|
||||
|
||||
Flux's built-in aggregate functions take values from an input table and aggregate them in some way.
|
||||
The output table contains a single row with the aggregated value.
|
||||
Flux's built-in aggregate transformations take values from an input table and aggregate them in some way.
|
||||
Output tables contain a single row with the aggregated value.
|
||||
|
||||
Aggregate operations output a table for every input table they receive.
|
||||
You must provide a column to aggregate.
|
||||
|
|
|
@ -5,11 +5,12 @@ description: >
|
|||
developed by Tushar Chande.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/chandemomentumoscillator/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: chandeMomentumOscillator
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#triple-exponential-moving-average, InfluxQL CHANDE_MOMENTUM_OSCILLATOR()
|
||||
---
|
||||
|
@ -17,7 +18,7 @@ related:
|
|||
The `chandeMomentumOscillator()` function applies the technical momentum indicator
|
||||
developed by Tushar Chande.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
chandeMomentumOscillator(
|
||||
|
@ -45,10 +46,16 @@ Defaults to `["_value"]`.
|
|||
|
||||
_**Data type: Array of Strings**_
|
||||
|
||||
## Output tables
|
||||
For each input table with `x` rows, `chandeMomentumOscillator()` outputs a table
|
||||
with `x - n` rows.
|
||||
|
||||
## Examples
|
||||
|
||||
#### Table transformation with a ten point Chande Momentum Oscillator
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
###### Input table
|
||||
| _time | _value |
|
||||
|:-----:|:------:|
|
||||
|
@ -81,7 +88,9 @@ _**Data type: Array of Strings**_
|
|||
| 0027 | 3 |
|
||||
| 0028 | 2 |
|
||||
| 0029 | 1 |
|
||||
{{% /flex-content %}}
|
||||
|
||||
{{% flex-content %}}
|
||||
###### Query
|
||||
```js
|
||||
// ...
|
||||
|
@ -110,3 +119,5 @@ _**Data type: Array of Strings**_
|
|||
| 0027 | -100 |
|
||||
| 0028 | -100 |
|
||||
| 0029 | -100 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
|
@ -4,17 +4,18 @@ description: The `cov()` function computes the covariance between two streams by
|
|||
aliases:
|
||||
- /v2.0/reference/flux/functions/transformations/aggregates/cov
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/cov/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/cov/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: cov
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
---
|
||||
|
||||
The `cov()` function computes the covariance between two streams by first joining the streams,
|
||||
then performing the covariance operation.
|
||||
|
||||
_**Function type:** Aggregate
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
|
@ -4,16 +4,17 @@ description: The `covariance()` function computes the covariance between two col
|
|||
aliases:
|
||||
- /v2.0/reference/flux/functions/transformations/aggregates/covariance
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/covariance/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/covariance/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: covariance
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
---
|
||||
|
||||
The `covariance()` function computes the covariance between two columns.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
|
@ -7,8 +7,10 @@ aliases:
|
|||
menu:
|
||||
v2_0_ref:
|
||||
name: derivative
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
aliases:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/derivative
|
||||
related:
|
||||
- /v2.0/query-data/flux/rate/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#derivative, InfluxQL – DERIVATIVE()
|
||||
|
@ -18,7 +20,7 @@ The `derivative()` function computes the rate of change per [`unit`](#unit) of t
|
|||
It assumes rows are ordered by the `_time` column.
|
||||
The output table schema is the same as the input table.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
||||
|
@ -56,6 +58,9 @@ Defaults to `"_time"`.
|
|||
|
||||
_**Data type:** String_
|
||||
|
||||
## Output tables
|
||||
For each input table with `n` rows, `derivative()` outputs a table with `n - 1` rows.
|
||||
|
||||
## Examples
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
|
@ -7,8 +7,10 @@ aliases:
|
|||
menu:
|
||||
v2_0_ref:
|
||||
name: difference
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
aliases:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/difference
|
||||
related:
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#difference, InfluxQL – DIFFERENCE()
|
||||
---
|
||||
|
@ -16,7 +18,7 @@ related:
|
|||
The `difference()` function computes the difference between subsequent records.
|
||||
The user-specified columns of numeric type are subtracted while others are kept intact.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
||||
|
@ -55,6 +57,8 @@ _**Data type:** Boolean_
|
|||
- Some value `v` minus `null` is `v` minus the last non-null value seen before `v`;
|
||||
or `null` if `v` is the first non-null value seen.
|
||||
|
||||
## Output tables
|
||||
For each input table with `n` rows, `difference()` outputs a table with `n - 1` rows.
|
||||
|
||||
## Examples
|
||||
|
|
@ -6,16 +6,17 @@ description: >
|
|||
the rate of `exponentialMovingAverage()`.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: doubleEMA
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#double-exponential-moving-average, InfluxQL DOUBLE_EXPONENTIAL_MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
|
@ -23,7 +24,7 @@ The `doubleEMA()` function calculates the exponential moving average of values i
|
|||
the `_value` column grouped into `n` number of points, giving more weight to recent
|
||||
data at double the rate of [`exponentialMovingAverage()`](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/).
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
doubleEMA(n: 5)
|
|
@ -5,16 +5,17 @@ description: >
|
|||
in the `_value` column grouped into `n` number of points, giving more weight to recent data.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: exponentialMovingAverage
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/tripleema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#exponential-moving-average, InfluxQL EXPONENTIAL_MOVING_AVERAGE()
|
||||
---
|
||||
|
|
@ -32,6 +32,19 @@ group(columns: ["_time"], mode:"except")
|
|||
group()
|
||||
```
|
||||
|
||||
{{% warn %}}
|
||||
#### Group does not guarantee sort order
|
||||
`group()` does not guarantee the sort order of output records.
|
||||
To ensure data is sorted correctly, use [`sort()`](/v2.0/reference/flux/stdlib/built-in/transformations/sort/)
|
||||
after `group()`.
|
||||
|
||||
```js
|
||||
data
|
||||
|> group()
|
||||
|> sort(columns: ["_time"])
|
||||
```
|
||||
{{% /warn %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
### columns
|
||||
|
|
|
@ -5,18 +5,19 @@ description: >
|
|||
aliases:
|
||||
- /v2.0/reference/flux/functions/transformations/aggregates/holtwinters
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/holtwinters/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/holtwinters/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: holtWinters
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#holt-winters, InfluxQL HOLT_WINTERS()
|
||||
---
|
||||
|
||||
The `holtWinters()` function applies the Holt-Winters forecasting method to input tables.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
|
@ -6,11 +6,12 @@ description: >
|
|||
aliases:
|
||||
- /v2.0/reference/flux/functions/transformations/aggregates/increase
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/increase/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: increase
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/query-data/flux/increase/
|
||||
---
|
||||
|
@ -22,7 +23,7 @@ when they hit a threshold or are reset.
|
|||
In the case of a wrap/reset, we can assume that the absolute delta between two
|
||||
points will be at least their non-negative difference.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
||||
|
@ -37,6 +38,9 @@ Defaults to `["_value"]`.
|
|||
|
||||
_**Data type:** Array of strings_
|
||||
|
||||
## Output tables
|
||||
For each input table with `n` rows, `derivative()` outputs a table with `n - 1` rows.
|
||||
|
||||
## Examples
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
||||
|
@ -48,6 +52,8 @@ from(bucket: "example-bucket")
|
|||
|> increase()
|
||||
```
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
Given the following input table:
|
||||
|
||||
| _time | _value |
|
||||
|
@ -56,7 +62,8 @@ Given the following input table:
|
|||
| 00002 | 5 |
|
||||
| 00003 | 3 |
|
||||
| 00004 | 4 |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{% flex-content %}}
|
||||
`increase()` produces the following table:
|
||||
|
||||
| _time | _value |
|
||||
|
@ -64,6 +71,8 @@ Given the following input table:
|
|||
| 00002 | 4 |
|
||||
| 00003 | 4 |
|
||||
| 00004 | 5 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
|
||||
## Function definition
|
||||
```js
|
|
@ -5,20 +5,21 @@ description: >
|
|||
using values in an input table.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/kaufmansama/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: kaufmansAMA
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/kaufmanser/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#kaufmans-adaptive-moving-average, InfluxQL KAUFMANS_ADAPTIVE_MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
The `kaufmansAMA()` function calculates the Kaufman's Adaptive Moving Average (KAMA)
|
||||
using values in an input table.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
kaufmansAMA(
|
|
@ -5,13 +5,14 @@ description: >
|
|||
values in an input table.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/kaufmanser/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: kaufmansER
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/kaufmansama/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#kaufmans-efficiency-ratio, InfluxQL KAUFMANS_EFFICIENCY_RATIO()
|
||||
---
|
||||
|
||||
|
@ -19,7 +20,7 @@ The `kaufmansER()` function calculates the Kaufman's Efficiency Ratio (KER) usin
|
|||
values in an input table.
|
||||
The function operates on the `_value` column.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
kaufmansER(n: 10)
|
|
@ -4,24 +4,25 @@ description: >
|
|||
The `movingAverage()` function calculates the mean of values grouped into `n` number of points.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/movingaverage/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: movingAverage
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/query-data/flux/moving-average/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/tripleema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
The `movingAverage()` function calculates the mean of values in the `_values` column
|
||||
grouped into `n` number of points.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
movingAverage(n: 5)
|
|
@ -4,17 +4,18 @@ description: The `pearsonr()` function computes the Pearson R correlation coeffi
|
|||
aliases:
|
||||
- /v2.0/reference/flux/functions/transformations/aggregates/pearsonr
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/pearsonr/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/pearsonr/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: pearsonr
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
---
|
||||
|
||||
The `pearsonr()` function computes the Pearson R correlation coefficient between two streams
|
||||
by first joining the streams, then performing the covariance operation normalized to compute R.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:** Float_
|
||||
|
||||
```js
|
|
@ -5,22 +5,23 @@ description: >
|
|||
values in an input table.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/relativestrengthindex/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/relativestrengthindex/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: relativeStrengthIndex
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#relative-strength-index, InfluxQL RELATIVE_STRENGTH_INDEX()
|
||||
---
|
||||
|
||||
The `relativeStrengthIndex()` function measures the relative speed and change of
|
||||
values in an input table.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
relativeStrengthIndex(
|
||||
|
@ -50,6 +51,10 @@ Columns to operate on. _Defaults to `["_value"]`_.
|
|||
|
||||
_**Data type:** Array of Strings_
|
||||
|
||||
## Output tables
|
||||
For each input table with `x` rows, `relativeStrengthIndex()` outputs a table
|
||||
with `x - n` rows.
|
||||
|
||||
## Examples
|
||||
|
||||
#### Calculate a five point relative strength index
|
||||
|
@ -61,6 +66,8 @@ from(bucket: "example-bucket"):
|
|||
|
||||
#### Table transformation with a ten point RSI
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
###### Input table:
|
||||
| _time | A | B | tag |
|
||||
|:-----:|:----:|:----:|:---:|
|
||||
|
@ -82,7 +89,8 @@ from(bucket: "example-bucket"):
|
|||
| 0016 | 16 | 16 | tv |
|
||||
| 0017 | 17 | null | tv |
|
||||
| 0018 | 18 | 17 | tv |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{% flex-content %}}
|
||||
###### Query:
|
||||
```js
|
||||
// ...
|
||||
|
@ -103,3 +111,5 @@ from(bucket: "example-bucket"):
|
|||
| 0016 | 90 | 90 | tv |
|
||||
| 0017 | 81 | 90 | tv |
|
||||
| 0018 | 72.9 | 81 | tv |
|
||||
{{% flex-content %}}
|
||||
{{< /flex >}}
|
|
@ -5,23 +5,24 @@ description: >
|
|||
range at a specified frequency.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: timedMovingAverage
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/tripleema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
The `timedMovingAverage()` function calculates the mean of values in a defined time
|
||||
range at a specified frequency.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
timedMovingAverage(
|
|
@ -6,16 +6,17 @@ description: >
|
|||
than `exponentialMovingAverage()` and `doubleEMA()`.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: tripleEMA
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#triple-exponential-moving-average, InfluxQL TRIPLE_EXPONENTIAL_MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
|
@ -25,7 +26,7 @@ data with less lag than
|
|||
[`exponentialMovingAverage()`](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/)
|
||||
and [`doubleEMA()`](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/).
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
tripleEMA(n: 5)
|
|
@ -5,18 +5,19 @@ description: >
|
|||
derivative (TRIX) of input tables using `n` points.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleexponentialderivative/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleexponentialderivative/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: tripleExponentialDerivative
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
parent: built-in-transformations
|
||||
weight: 402
|
||||
v2.0/tags: [technical analysis]
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/movingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/doubleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/tripleema/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage/
|
||||
- /v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#triple-exponential-derivative, InfluxQL TRIPLE_EXPONENTIAL_DERIVATIVE()
|
||||
---
|
||||
|
||||
|
@ -24,7 +25,7 @@ The `tripleExponentialDerivative()` function calculates a triple exponential
|
|||
derivative ([TRIX](https://en.wikipedia.org/wiki/Trix_(technical_analysis))) of
|
||||
input tables using `n` points.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
tripleExponentialDerivative(n: 5)
|
|
@ -5,7 +5,7 @@ description: >
|
|||
User-contributed packages and functions are contributed and maintained by members of the InfluxDB and Flux communities.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: User-contributed
|
||||
name: Contributed
|
||||
parent: Flux standard library
|
||||
weight: 202
|
||||
v2.0/tags: [contributed, functions, package]
|
||||
|
|
|
@ -7,7 +7,7 @@ description: >
|
|||
menu:
|
||||
v2_0_ref:
|
||||
name: Discord
|
||||
parent: User-contributed
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
v2.0/tags: [functions, discord, package]
|
||||
---
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
title: Flux Microsoft Teams package
|
||||
list_title: Microsoft Teams package
|
||||
description: >
|
||||
The Flux Microsoft Teams package provides functions for sending messages to a
|
||||
[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
|
||||
channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
Import the `contrib/sranka/teams` package.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Teams
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
v2.0/tags: [functions, teams, microsoft, package]
|
||||
---
|
||||
|
||||
The Flux Microsoft Teams package provides functions for sending messages to a
|
||||
[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
|
||||
channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
Import the `contrib/sranka/teams` package:
|
||||
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
```
|
||||
|
||||
{{< children type="functions" show="pages" >}}
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
title: teams.endpoint() function
|
||||
description: >
|
||||
The `teams.endpoint()` function sends a message to a Microsoft Teams channel
|
||||
using data from table rows.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: teams.endpoint
|
||||
parent: Teams
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `teams.endpoint()` function sends a message to a Microsoft Teams channel
|
||||
using data from table rows.
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
teams.endpoint(
|
||||
url: "https://outlook.office.com/webhook/example-webhook"
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
Incoming webhook URL.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Usage
|
||||
`teams.endpoint` is a factory function that outputs another function.
|
||||
The output function requires a `mapFn` parameter.
|
||||
|
||||
### mapFn
|
||||
A function that builds the object used to generate the POST request.
|
||||
Requires an `r` parameter.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
`mapFn` accepts a table row (`r`) and returns an object that must include the
|
||||
following fields:
|
||||
|
||||
- `title`
|
||||
- `text`
|
||||
- `summary`
|
||||
|
||||
_For more information, see [`teams.message()`](/v2.0/reference/flux/stdlib/contrib/teams/message/)._
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send critical statuses to a Microsoft Teams channel
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
url = "https://outlook.office.com/webhook/example-webhook"
|
||||
endpoint = teams.endpoint(url: url)
|
||||
|
||||
crit_statuses = from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
|
||||
|
||||
crit_statuses
|
||||
|> endpoint(mapFn: (r) => ({
|
||||
title: "Disk Usage"
|
||||
text: "Disk usage is: **${r.status}**.",
|
||||
summary: "Disk usage is ${r.status}"
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
title: teams.message() function
|
||||
description: >
|
||||
The `teams.message()` function sends a single message to a Microsoft Teams channel using
|
||||
an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: teams.message
|
||||
parent: Teams
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `teams.message()` function sends a single message to a Microsoft Teams channel using
|
||||
an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
teams.message(
|
||||
url: "https://outlook.office.com/webhook/example-webhook",
|
||||
title: "Example message title",
|
||||
text: "Example message text",
|
||||
summary: "",
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
Incoming webhook URL.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### title
|
||||
Message card title.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### text
|
||||
Message card text.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### summary
|
||||
Message card summary.
|
||||
Default is `""`.
|
||||
If no summary is provided, Flux generates the summary from the message text.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send the last reported status to a Microsoft Teams channel
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
lastReported =
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses")
|
||||
|> last()
|
||||
|> findRecord(fn: (key) => true, idx: 0)
|
||||
|
||||
teams.message(
|
||||
url: "https://outlook.office.com/webhook/example-webhook",
|
||||
title: "Disk Usage"
|
||||
text: "Disk usage is: *${lastReported.status}*.",
|
||||
summary: "Disk usage is ${lastReported.status}"
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
title: Flux Telegram package
|
||||
list_title: Telegram package
|
||||
description: >
|
||||
The Flux Telegram package provides functions for sending messages to
|
||||
[Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||
Import the `contrib/sranka/telegram` package.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Telegram
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
v2.0/tags: [functions, teams, microsoft, package]
|
||||
---
|
||||
|
||||
The Flux Telegram package provides functions for sending messages to
|
||||
[Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||
Import the `contrib/sranka/telegram` package:
|
||||
|
||||
```js
|
||||
import "contrib/sranka/telegram"
|
||||
```
|
||||
|
||||
{{< children type="functions" show="pages" >}}
|
||||
|
||||
## Set up a Telegram bot
|
||||
The **Telegram Bot API** requires a **bot token** and a **channel ID**.
|
||||
To set up a Telegram bot and obtain the required bot token and channel ID:
|
||||
|
||||
1. [Create a new Telegram account](https://telegram.org/) or use an existing account.
|
||||
2. [Create a Telegram bot](https://core.telegram.org/bots#creating-a-new-bot).
|
||||
Telegram provides a **bot token** for the newly created bot.
|
||||
3. Use the **Telegram application** to create a new channel.
|
||||
4. [Add the new bot to the channel](https://stackoverflow.com/questions/33126743/how-do-i-add-my-bot-to-a-channel) as an **Administrator**.
|
||||
Ensure the bot has permissions necessary to **post messages**.
|
||||
5. Send a message to bot in the channel.
|
||||
6. Send a request to `https://api.telegram.org/bot$token/getUpdates`.
|
||||
|
||||
```sh
|
||||
curl https://api.telegram.org/bot$token/getUpdates
|
||||
```
|
||||
|
||||
Find your **channel ID** in the `id` field of the response.
|
||||
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,106 @@
|
|||
---
|
||||
title: telegram.endpoint() function
|
||||
description: >
|
||||
The `telegram.endpoint()` function sends a message to a Telegram channel
|
||||
using data from table rows.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: telegram.endpoint
|
||||
parent: Telegram
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `telegram.endpoint()` function sends a message to a Telegram channel
|
||||
using data from table rows.
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/sranka/telegram"
|
||||
|
||||
telegram.endpoint(
|
||||
url: "https://api.telegram.org/bot",
|
||||
token: "S3crEtTel3gRamT0k3n",
|
||||
parseMode: "MarkdownV2",
|
||||
disableWebPagePreview: false,
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
For information about retrieving your Telegram **bot token** and **channel ID**,
|
||||
see [Set up a Telegram bot](/v2.0/reference/flux/stdlib/contrib/telegram/#set-up-a-telegram-bot).
|
||||
{{% /note %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
URL of the Telegram bot endpoint.
|
||||
Default is `https://api.telegram.org/bot`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### token
|
||||
<span class="req">Required</span>
|
||||
Telegram bot token.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### parseMode
|
||||
[Parse mode](https://core.telegram.org/bots/api#formatting-options) of the message text.
|
||||
Default is `"MarkdownV2"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### disableWebPagePreview
|
||||
Disable preview of web links in the sent message.
|
||||
Default is `false`.
|
||||
|
||||
_**Data type:** Boolean_
|
||||
|
||||
## Usage
|
||||
`telegram.endpoint` is a factory function that outputs another function.
|
||||
The output function requires a `mapFn` parameter.
|
||||
|
||||
### mapFn
|
||||
A function that builds the object used to generate the POST request.
|
||||
Requires an `r` parameter.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
`mapFn` accepts a table row (`r`) and returns an object that must include the
|
||||
following fields:
|
||||
|
||||
- `channel`
|
||||
- `text`
|
||||
- `silent`
|
||||
|
||||
_For more information, see [`telegram.message()`](/v2.0/reference/flux/stdlib/contrib/telegram/message/)._
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send critical statuses to a Telegram channel
|
||||
```js
|
||||
import "influxdata/influxdb/secrets"
|
||||
import "contrib/sranka/telegram"
|
||||
|
||||
token = secrets.get(key: "TELEGRAM_TOKEN")
|
||||
endpoint = telegram.endpoint(token: token)
|
||||
|
||||
crit_statuses = from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
|
||||
|
||||
crit_statuses
|
||||
|> endpoint(mapFn: (r) => ({
|
||||
channel: "-12345",
|
||||
text: "Disk usage is **${r.status}**.",
|
||||
silent: true
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,107 @@
|
|||
---
|
||||
title: telegram.message() function
|
||||
description: >
|
||||
The `telegram.message()` function sends a single message to a Telegram channel using
|
||||
the [`sendMessage` method of the Telegram Bot API](https://core.telegram.org/bots/api#sendmessage).
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: telegram.message
|
||||
parent: Telegram
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `telegram.message()` function sends a single message to a Telegram channel using
|
||||
the [`sendMessage` method of the Telegram Bot API](https://core.telegram.org/bots/api#sendmessage).
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/sranka/telegram"
|
||||
|
||||
telegram.message(
|
||||
url: "https://api.telegram.org/bot",
|
||||
token: "S3crEtTel3gRamT0k3n",
|
||||
channel: "-12345",
|
||||
text: "Example message text",
|
||||
parseMode: "MarkdownV2",
|
||||
disableWebPagePreview: false,
|
||||
silent: true
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
For information about retrieving your Telegram **bot token** and **channel ID**,
|
||||
see [Set up a Telegram bot](/v2.0/reference/flux/stdlib/contrib/telegram/#set-up-a-telegram-bot).
|
||||
{{% /note %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
URL of the Telegram bot endpoint.
|
||||
Default is `https://api.telegram.org/bot`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### token
|
||||
<span class="req">Required</span>
|
||||
Telegram bot token.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### channel
|
||||
<span class="req">Required</span>
|
||||
Telegram channel ID.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### text
|
||||
Message text.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### parseMode
|
||||
[Parse mode](https://core.telegram.org/bots/api#formatting-options) of the message text.
|
||||
Default is `"MarkdownV2"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### disableWebPagePreview
|
||||
Disable preview of web links in the sent message.
|
||||
Default is `false`.
|
||||
|
||||
_**Data type:** Boolean_
|
||||
|
||||
### silent
|
||||
Send message [silently](https://telegram.org/blog/channels-2-0#silent-messages).
|
||||
Default is `true`.
|
||||
|
||||
_**Data type:** Boolean_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send the last reported status to a Microsoft Teams channel
|
||||
```js
|
||||
import "influxdata/influxdb/secrets"
|
||||
import "contrib/sranka/telegram"
|
||||
|
||||
token = secrets.get(key: "TELEGRAM_TOKEN")
|
||||
|
||||
lastReported =
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses")
|
||||
|> last()
|
||||
|> findRecord(fn: (key) => true, idx: 0)
|
||||
|
||||
telegram.message(
|
||||
token: token,
|
||||
channel: "-12345"
|
||||
text: "Disk usage is **${lastReported.status}**.",
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -29,5 +29,29 @@ date.hour(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the hour of a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.hour(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 12
|
||||
```
|
||||
|
||||
##### Return the hour of a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.hour(t: -8h)
|
||||
|
||||
// Returns 4
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.microsecond(t: 2019-07-17T12:05:21.012934584Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the microsecond of a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.microsecond(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 293534
|
||||
```
|
||||
|
||||
##### Return the microsecond of a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.microsecond(t: -1890us)
|
||||
|
||||
// Returns 291644
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.millisecond(t: 2019-07-17T12:05:21.012934584Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the millisecond of a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.millisecond(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 293
|
||||
```
|
||||
|
||||
##### Return the millisecond of a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.millisecond(t: -150ms)
|
||||
|
||||
// Returns 143
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.minute(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the minute of a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.minute(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 21
|
||||
```
|
||||
|
||||
##### Return the minute of a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.minute(t: -45m)
|
||||
|
||||
// Returns 36
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.month(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the month of a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.month(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 2
|
||||
```
|
||||
|
||||
##### Return the month of a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.month(t: -3mo)
|
||||
|
||||
// Returns 11
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.monthDay(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the day of the month for a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.monthDay(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 11
|
||||
```
|
||||
|
||||
##### Return the day of the month for a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.monthDay(t: -8d)
|
||||
|
||||
// Returns 3
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.nanosecond(t: 2019-07-17T12:05:21.012934584Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the nanosecond for a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.nanosecond(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 293534940Z
|
||||
```
|
||||
|
||||
##### Return the nanosecond for a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.nanosecond(t: -2111984ns)
|
||||
|
||||
// Returns 291422956
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.quarter(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the quarter for a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.quarter(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 1
|
||||
```
|
||||
|
||||
##### Return the quarter for a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.quarter(t: -7mo)
|
||||
|
||||
// Returns 3
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.second(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the second of a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.second(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 3
|
||||
```
|
||||
|
||||
##### Return the second of a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.second(t: -50s)
|
||||
|
||||
// Returns 13
|
||||
```
|
||||
|
|
|
@ -30,8 +30,10 @@ date.truncate(
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
### unit
|
||||
The unit of time to truncate to.
|
||||
|
@ -44,16 +46,33 @@ For example: `1s`, `1m`, `1h`.
|
|||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
||||
##### Truncate time values
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1s)
|
||||
// Returns 2019-06-03T13:59:01.000000000Z
|
||||
date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1s)
|
||||
// Returns 2019-06-03T13:59:01.000000000Z
|
||||
|
||||
date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1m)
|
||||
// Returns 2019-06-03T13:59:00.000000000Z
|
||||
|
||||
date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1h)
|
||||
// Returns 2019-06-03T13:00:00.000000000Z
|
||||
date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1m)
|
||||
// Returns 2019-06-03T13:59:00.000000000Z
|
||||
|
||||
date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1h)
|
||||
// Returns 2019-06-03T13:00:00.000000000Z
|
||||
```
|
||||
|
||||
##### Truncate time values using durations
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-01-01T00:00:30.500000000Z
|
||||
|
||||
date.truncate(t: -30s, unit: 1s)
|
||||
// Returns 2019-12-31T23:59:30.000000000Z
|
||||
|
||||
date.truncate(t: -1m, unit: 1m)
|
||||
// Returns 2019-12-31T23:59:00.000000000Z
|
||||
|
||||
date.truncate(t: -1h, unit: 1h)
|
||||
// Returns 2019-12-31T23:00:00.000000000Z
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.week(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the week of the year
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.week(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 7
|
||||
```
|
||||
|
||||
##### Return the week of the year using a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.week(t: -12d)
|
||||
|
||||
// Returns 5
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.weekDay(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the day of the week for a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.weekDay(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 2
|
||||
```
|
||||
|
||||
##### Return the day of the week for a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.weekDay(t: -84h)
|
||||
|
||||
// Returns 6
|
||||
```
|
||||
|
|
|
@ -27,5 +27,29 @@ date.year(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the year for a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.year(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 2020
|
||||
```
|
||||
|
||||
##### Return the year for a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.year(t: -14y)
|
||||
|
||||
// Returns 2006
|
||||
```
|
||||
|
|
|
@ -29,5 +29,29 @@ date.yearDay(t: 2019-07-17T12:05:21.012Z)
|
|||
|
||||
### t
|
||||
The time to operate on.
|
||||
Use an absolute time or relative duration.
|
||||
Durations are relative to `now()`.
|
||||
|
||||
_**Data type:** Time_
|
||||
_**Data type:** Time | Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Return the day of the year for a time value
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.yearDay(t: 2020-02-11T12:21:03.293534940Z)
|
||||
|
||||
// Returns 42
|
||||
```
|
||||
|
||||
##### Return the day of the year for a relative duration
|
||||
```js
|
||||
import "date"
|
||||
|
||||
option now = () => 2020-02-11T12:21:03.293534940Z
|
||||
|
||||
date.yearDay(t: -1mo)
|
||||
|
||||
// Returns 11
|
||||
```
|
||||
|
|
|
@ -3,7 +3,7 @@ title: Flux SQL package
|
|||
list_title: SQL package
|
||||
description: >
|
||||
The Flux SQL package provides tools for working with data in SQL databases such
|
||||
as MySQL, PostgreSQL, and SQLite.
|
||||
as MySQL, PostgreSQL, Snowflake, SQLite, Microsoft SQL Server, and Amazon Athena.
|
||||
Import the `sql` package.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/sql/
|
||||
|
@ -17,8 +17,15 @@ related:
|
|||
- /v2.0/query-data/flux/sql/
|
||||
---
|
||||
|
||||
SQL Flux functions provide tools for working with data in SQL databases such as
|
||||
MySQL, PostgreSQL, Snowflake, and SQLite.
|
||||
SQL Flux functions provide tools for working with data in SQL databases such as:
|
||||
|
||||
- Amazon Athena
|
||||
- Microsoft SQL Server
|
||||
- MySQL
|
||||
- PostgreSQL
|
||||
- Snowflake
|
||||
- SQLite
|
||||
|
||||
Import the `sql` package:
|
||||
|
||||
```js
|
||||
|
|
|
@ -35,10 +35,12 @@ _**Data type:** String_
|
|||
|
||||
The following drivers are available:
|
||||
|
||||
- awsathena
|
||||
- mysql
|
||||
- postgres
|
||||
- snowflake
|
||||
- sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#query-an-sqlite-database)._
|
||||
- sqlserver, mssql
|
||||
|
||||
### dataSourceName
|
||||
The data source name (DSN) or connection string used to connect to the SQL database.
|
||||
|
@ -48,12 +50,16 @@ _**Data type:** String_
|
|||
|
||||
##### Driver dataSourceName examples
|
||||
```sh
|
||||
# Postgres Driver DSN
|
||||
postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
|
||||
# Amazon Athena Driver DSN
|
||||
s3://myorgqueryresults/?accessID=AKIAJLO3F...®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...
|
||||
s3://myorgqueryresults/?accessID=AKIAJLO3F...&db=dbname&missingAsDefault=false&missingAsEmptyString=false®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...&WGRemoteCreation=false
|
||||
|
||||
# MySQL Driver DSN
|
||||
username:password@tcp(localhost:3306)/dbname?param=value
|
||||
|
||||
# Postgres Driver DSN
|
||||
postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
|
||||
|
||||
# Snowflake Driver DSNs
|
||||
username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN
|
||||
username[:password]@accountname/dbname?param1=value1¶mN=valueN
|
||||
|
@ -61,6 +67,12 @@ username[:password]@hostname:port/dbname/schemaname?account=<your_account>¶m
|
|||
|
||||
# SQLite Driver DSN
|
||||
file:/path/to/test.db?cache=shared&mode=ro
|
||||
|
||||
# Microsoft SQL Server Driver DSNs
|
||||
sqlserver://username:password@localhost:1234?database=examplebdb
|
||||
server=localhost;user id=username;database=examplebdb;
|
||||
server=localhost;user id=username;database=examplebdb;azure auth=ENV
|
||||
server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789
|
||||
```
|
||||
|
||||
### query
|
||||
|
@ -70,6 +82,13 @@ _**Data type:** String_
|
|||
|
||||
## Examples
|
||||
|
||||
- [MySQL](#query-a-mysql-database)
|
||||
- [Postgres](#query-a-postgres-database)
|
||||
- [Snowflake](#query-a-snowflake-database)
|
||||
- [SQLite](#query-an-sqlite-database)
|
||||
- [Amazon Athena](#query-an-amazon-athena-database)
|
||||
- [SQL Server](#query-a-sql-server-database)
|
||||
|
||||
{{% note %}}
|
||||
The examples below use [InfluxDB secrets](/v2.0/security/secrets/) to populate
|
||||
sensitive connection credentials.
|
||||
|
@ -139,3 +158,95 @@ sql.from(
|
|||
query: "SELECT * FROM example_table"
|
||||
)
|
||||
```
|
||||
|
||||
### Query an Amazon Athena database
|
||||
```js
|
||||
import "sql"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
region = us-west-1
|
||||
accessID = secrets.get(key: "ATHENA_ACCESS_ID")
|
||||
secretKey = secrets.get(key: "ATHENA_SECRET_KEY")
|
||||
|
||||
sql.from(
|
||||
driverName: "awsathena",
|
||||
dataSourceName: "s3://myorgqueryresults/?accessID=${accessID}®ion=${region}&secretAccessKey=${secretKey}",
|
||||
query:"SELECT * FROM example_table"
|
||||
)
|
||||
```
|
||||
|
||||
##### Athena connection string
|
||||
To query an Amazon Athena database, use the following query parameters in your Athena
|
||||
S3 connection string (DSN):
|
||||
|
||||
<span class="req">\* Required</span>
|
||||
|
||||
- **region** - AWS region <span class="req">\*</span>
|
||||
- **accessID** - AWS IAM access ID <span class="req">\*</span>
|
||||
- **secretAccessKey** - AWS IAM secret key <span class="req">\*</span>
|
||||
- **db** - database name
|
||||
- **WGRemoteCreation** - controls workgroup and tag creation
|
||||
- **missingAsDefault** - replace missing data with default values
|
||||
- **missingAsEmptyString** - replace missing data with empty strings
|
||||
|
||||
|
||||
### Query a SQL Server database
|
||||
```js
|
||||
import "sql"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
username = secrets.get(key: "SQLSERVER_USER")
|
||||
password = secrets.get(key: "SQLSERVER_PASS")
|
||||
|
||||
sql.from(
|
||||
driverName: "sqlserver",
|
||||
dataSourceName: "sqlserver://${username}:${password}@localhost:1234?database=examplebdb",
|
||||
query: "GO SELECT * FROM Example.Table"
|
||||
)
|
||||
```
|
||||
|
||||
#### SQL Server ADO authentication
|
||||
Use one of the following methods to provide SQL Server authentication credentials as
|
||||
[ActiveX Data Objects (ADO)](https://docs.microsoft.com/en-us/sql/ado/guide/ado-introduction?view=sql-server-ver15)
|
||||
connection string parameters:
|
||||
|
||||
- [Retrieve authentication credentials from environment variables](#retrieve-authentication-credentials-from-environment-variables)
|
||||
- [Retrieve authentication credentials from a file](#retrieve-authentication-credentials-from-a-file)
|
||||
- [Specify authentication credentials in the connection string](#specify-authentication-credentials-in-the-connection-string)
|
||||
- [Use a Managed identity in an Azure VM](#use-a-managed-identity-in-an-azure-vm)
|
||||
|
||||
##### Retrieve authentication credentials from environment variables
|
||||
```
|
||||
azure auth=ENV
|
||||
```
|
||||
|
||||
##### Retrieve authentication credentials from a file
|
||||
{{% warn %}}
|
||||
**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ provide
|
||||
access to the underlying file system and do not support reading credentials from a file.
|
||||
To retrieve SQL Server credentials from a file, execute the query in the
|
||||
[Flux REPL](/v2.0/reference/cli/influx/repl/) on your local machine.
|
||||
{{% /warn %}}
|
||||
|
||||
```powershel
|
||||
azure auth=C:\secure\azure.auth
|
||||
```
|
||||
|
||||
##### Specify authentication credentials in the connection string
|
||||
```powershell
|
||||
# Example of providing tenant ID, client ID, and client secret token
|
||||
azure tenant id=77...;azure client id=58...;azure client secret=0cf123..
|
||||
|
||||
# Example of providing tenant ID, client ID, certificate path and certificate password
|
||||
azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY...
|
||||
|
||||
# Example of providing tenant ID, client ID, and Azure username and password
|
||||
azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1...
|
||||
```
|
||||
|
||||
##### Use a managed identity in an Azure VM
|
||||
_For information about managed identities, see [Microsoft managed identities](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview)._
|
||||
|
||||
```
|
||||
azure auth=MSI
|
||||
```
|
||||
|
|
|
@ -38,6 +38,7 @@ The following drivers are available:
|
|||
- postgres
|
||||
- snowflake
|
||||
- sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#write-data-to-an-sqlite-database)._
|
||||
- sqlserver, mssql
|
||||
|
||||
### dataSourceName
|
||||
The data source name (DSN) or connection string used to connect to the SQL database.
|
||||
|
@ -60,6 +61,12 @@ username[:password]@hostname:port/dbname/schemaname?account=<your_account>¶m
|
|||
|
||||
# SQLite Driver DSN
|
||||
file:/path/to/test.db?cache=shared&mode=rw
|
||||
|
||||
# Microsoft SQL Server Driver DSNs
|
||||
sqlserver://username:password@localhost:1234?database=examplebdb
|
||||
server=localhost;user id=username;database=examplebdb;
|
||||
server=localhost;user id=username;database=examplebdb;azure auth=ENV
|
||||
server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789
|
||||
```
|
||||
|
||||
### table
|
||||
|
@ -79,6 +86,12 @@ If writing to a **SQLite** database, set `batchSize` to `999` or less.
|
|||
|
||||
## Examples
|
||||
|
||||
- [MySQL](#write-data-to-a-mysql-database)
|
||||
- [Postgres](#write-data-to-a-postgres-database)
|
||||
- [Snowflake](#write-data-to-a-snowflake-database)
|
||||
- [SQLite](#write-data-to-an-sqlite-database)
|
||||
- [SQL Server](#write-data-to-a-sql-server-database)
|
||||
|
||||
{{% note %}}
|
||||
The examples below use [InfluxDB secrets](/v2.0/security/secrets/) to populate
|
||||
sensitive connection credentials.
|
||||
|
@ -148,3 +161,69 @@ sql.to(
|
|||
table: "example_table"
|
||||
)
|
||||
```
|
||||
|
||||
### Write data to a SQL Server database
|
||||
```js
|
||||
import "sql"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
username = secrets.get(key: "SQLSERVER_USER")
|
||||
password = secrets.get(key: "SQLSERVER_PASS")
|
||||
|
||||
sql.to(
|
||||
driverName: "sqlserver",
|
||||
dataSourceName: "sqlserver://${username}:${password}@localhost:1234?database=examplebdb",
|
||||
table: "Example.Table"
|
||||
)
|
||||
```
|
||||
|
||||
#### SQL Server ADO authentication
|
||||
Use one of the following methods to provide SQL Server authentication credentials as
|
||||
[ActiveX Data Objects (ADO)](https://docs.microsoft.com/en-us/sql/ado/guide/ado-introduction?view=sql-server-ver15)
|
||||
connection string parameters:
|
||||
|
||||
- [Retrieve authentication credentials from environment variables](#retrieve-authentication-credentials-from-environment-variables)
|
||||
- [Retrieve authentication credentials from a file](#retrieve-authentication-credentials-from-a-file)
|
||||
- [Specify authentication credentials in the connection string](#specify-authentication-credentials-in-the-connection-string)
|
||||
- [Use a Managed identity in an Azure VM](#use-a-managed-identity-in-an-azure-vm)
|
||||
|
||||
##### Retrieve authentication credentials from environment variables
|
||||
```
|
||||
azure auth=ENV
|
||||
```
|
||||
|
||||
##### Retrieve authentication credentials from a file
|
||||
{{% warn %}}
|
||||
**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ provide
|
||||
access to the underlying file system and do not support reading credentials from a file.
|
||||
To retrieve SQL Server credentials from a file, execute the query in the
|
||||
[Flux REPL](/v2.0/reference/cli/influx/repl/) on your local machine.
|
||||
{{% /warn %}}
|
||||
|
||||
```powershell
|
||||
azure auth=C:\secure\azure.auth
|
||||
```
|
||||
|
||||
##### Specify authentication credentials in the connection string
|
||||
```powershell
|
||||
# Example of providing tenant ID, client ID, and client secret token
|
||||
azure tenant id=77...;azure client id=58...;azure client secret=0cf123..
|
||||
|
||||
# Example of providing tenant ID, client ID, certificate path and certificate password
|
||||
azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY...
|
||||
|
||||
# Example of providing tenant ID, client ID, and Azure username and password
|
||||
azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1...
|
||||
```
|
||||
|
||||
##### Use a managed identity in an Azure VM
|
||||
_For information about managed identities, see [Microsoft managed identities](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview)._
|
||||
|
||||
```
|
||||
azure auth=MSI
|
||||
```
|
||||
|
||||
{{% warn %}}
|
||||
### sql.to does not support Amazon Athena
|
||||
The `sql.to` function does not support writing data to [Amazon Athena](https://aws.amazon.com/athena/).
|
||||
{{% /warn %}}
|
||||
|
|
|
@ -16,6 +16,28 @@ Though newer versions of Flux may be available, they will not be included with
|
|||
InfluxDB until the next InfluxDB v2.0 release._
|
||||
{{% /note %}}
|
||||
|
||||
## v0.70.0 [2020-06-29]
|
||||
### Features
|
||||
- Update all `date` functions to accept time and duration types.
|
||||
- Add [Microsoft Teams package](/v2.0/reference/flux/stdlib/contrib/teams/).
|
||||
- Evaluate and store `now` in execution dependencies for `tableFind()`.
|
||||
- Add `Timeable` constraint for time and duration types.
|
||||
- Add [SQL Server support](/v2.0/reference/flux/stdlib/sql/from/#query-a-sql-server-database) to `sql` package.
|
||||
- Add [Telegram package](/v2.0/reference/flux/stdlib/contrib/telegram/).
|
||||
- Add [Amazon Athena support](/v2.0/reference/flux/stdlib/sql/from/#query-an-amazon-athena-database) to `sql` package.
|
||||
- Add support for macOS builds.
|
||||
|
||||
### Bug fixes
|
||||
- Move semantic analysis to the finalize step.
|
||||
- Fix check for stream equality.
|
||||
- Fix the compiler's return type when `with` operator is used.
|
||||
- Include `stdlib` Flux dependencies from the Flux `build.rs`.
|
||||
- Include a hash of the sources for `libflux`.
|
||||
- Flux test for [experimental `json.parse()`](/v2.0/reference/flux/stdlib/experimental/json/parse/).
|
||||
- Reorder `go generate` call to `libflux` in `stdlib`.
|
||||
|
||||
---
|
||||
|
||||
## v0.69.2 [2020-06-10]
|
||||
|
||||
### Bug fixes
|
||||
|
|
Loading…
Reference in New Issue