From 1d9dbc8369e8df37decb6efb42941105d1793b82 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 18 May 2020 11:24:16 -0600 Subject: [PATCH 01/22] added sql server to sql docs, resolves #1047 --- content/v2.0/query-data/flux/sql.md | 17 ++++++++++++-- .../v2.0/reference/flux/stdlib/sql/_index.md | 4 ++-- .../v2.0/reference/flux/stdlib/sql/from.md | 22 +++++++++++++++++++ content/v2.0/reference/flux/stdlib/sql/to.md | 22 +++++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/content/v2.0/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index 6baee5ac5..8d0a4db3e 100644 --- a/content/v2.0/query-data/flux/sql.md +++ b/content/v2.0/query-data/flux/sql.md @@ -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, and MS SQL Server. v2.0/tags: [query, flux, sql] menu: v2_0: @@ -30,7 +31,8 @@ list_code_example: | The [Flux](/v2.0/reference/flux) `sql` package provides functions for working with SQL data sources. [`sql.from()`](/v2.0/reference/flux/stdlib/sql/from/) lets you query SQL data sources like [PostgreSQL](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), -[Snowflake](https://www.snowflake.com/), and [SQLite](https://www.sqlite.org/index.html), +[Snowflake](https://www.snowflake.com/), [SQLite](https://www.sqlite.org/index.html), +and [MS SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx), and use the results with InfluxDB dashboards, tasks, and other operations. - [Query a SQL data source](#query-a-sql-data-source) @@ -57,6 +59,7 @@ To query a SQL data source: [MySQL](#) [Snowflake](#) [SQLite](#) +[SQL Server](#) {{% /code-tabs %}} {{% code-tab-content %}} @@ -110,6 +113,16 @@ sql.from( ) ``` {{% /code-tab-content %}} + +{{% code-tab-content %}} +```js +sql.from( + driverName: "sqlserver", + dataSourceName: "sqlserver://user:password@localhost:1234?database=examplebdb", + query: "GO SELECT * FROM Example.Table" +) +``` +{{% /code-tab-content %}} {{< /code-tabs-wrapper >}} _See the [`sql.from()` documentation](/v2.0/reference/flux/stdlib/sql/from/) for diff --git a/content/v2.0/reference/flux/stdlib/sql/_index.md b/content/v2.0/reference/flux/stdlib/sql/_index.md index 2fd8814e0..0b393d83d 100644 --- a/content/v2.0/reference/flux/stdlib/sql/_index.md +++ b/content/v2.0/reference/flux/stdlib/sql/_index.md @@ -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, and MS SQL Server. Import the `sql` package. aliases: - /v2.0/reference/flux/functions/sql/ @@ -18,7 +18,7 @@ related: --- SQL Flux functions provide tools for working with data in SQL databases such as -MySQL, PostgreSQL, Snowflake, and SQLite. +MySQL, PostgreSQL, Snowflake, SQLite, and MS SQL Server. Import the `sql` package: ```js diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index 0ecc56666..e92e04474 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -39,6 +39,7 @@ The following drivers are available: - 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. @@ -61,6 +62,12 @@ username[:password]@hostname:port/dbname/schemaname?account=¶m # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=ro + +# MS 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 @@ -139,3 +146,18 @@ sql.from( query: "SELECT * FROM example_table" ) ``` + +### 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" +) +``` diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index 4d94200ef..f4a4a071d 100644 --- a/content/v2.0/reference/flux/stdlib/sql/to.md +++ b/content/v2.0/reference/flux/stdlib/sql/to.md @@ -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=¶m # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=rw + +# MS 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 @@ -148,3 +155,18 @@ 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" +) +``` From 021d77113a70136ddd3969e71f86867a007e2d46 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 26 May 2020 16:58:11 -0600 Subject: [PATCH 02/22] added sql server auth info to sql docs --- content/v2.0/query-data/flux/sql.md | 5 ++++ .../v2.0/reference/flux/stdlib/sql/from.md | 27 +++++++++++++++++++ content/v2.0/reference/flux/stdlib/sql/to.md | 27 +++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/content/v2.0/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index 8d0a4db3e..74a416c43 100644 --- a/content/v2.0/query-data/flux/sql.md +++ b/content/v2.0/query-data/flux/sql.md @@ -116,12 +116,17 @@ sql.from( {{% 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 >}} diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index e92e04474..17299a638 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -161,3 +161,30 @@ sql.from( query: "GO SELECT * FROM Example.Table" ) ``` + +#### SQL Server ADO authentication +Use one of the 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 +``` +azure auth=ENV +``` + +##### Retrieve authentication credentials from a file +``` +azure auth=c:\secure\azure.auth +``` + +##### Specify authentication credentials in the connection string +``` +azure tenant id=77...;azure client id=58...;azure client secret=0cf123.. +azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY... +azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1... +``` + +##### Use a Managed identity in an Azure VM +``` +azure auth=MSI +``` diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index f4a4a071d..4f816d798 100644 --- a/content/v2.0/reference/flux/stdlib/sql/to.md +++ b/content/v2.0/reference/flux/stdlib/sql/to.md @@ -170,3 +170,30 @@ sql.to( table: "Example.Table" ) ``` + +#### SQL Server ADO authentication +Use one of the 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 +``` +azure auth=ENV +``` + +##### Retrieve authentication credentials from a file +``` +azure auth=c:\secure\azure.auth +``` + +##### Specify authentication credentials in the connection string +``` +azure tenant id=77...;azure client id=58...;azure client secret=0cf123.. +azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY... +azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1... +``` + +##### Use a Managed identity in an Azure VM +``` +azure auth=MSI +``` From 6c8749c509c21a8bbb3ee4ecb9dc429d61833976 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 26 May 2020 17:05:13 -0600 Subject: [PATCH 03/22] added warning about reading sql server creds from a file --- content/v2.0/reference/flux/stdlib/sql/from.md | 7 +++++++ content/v2.0/reference/flux/stdlib/sql/to.md | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index 17299a638..432569d76 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -173,6 +173,13 @@ 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 %}} + ``` azure auth=c:\secure\azure.auth ``` diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index 4f816d798..7cc25aafc 100644 --- a/content/v2.0/reference/flux/stdlib/sql/to.md +++ b/content/v2.0/reference/flux/stdlib/sql/to.md @@ -182,6 +182,13 @@ 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 %}} + ``` azure auth=c:\secure\azure.auth ``` From 7cc5de7f4a7accf4294610865bf077721aa4e54a Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 27 May 2020 09:00:01 -0600 Subject: [PATCH 04/22] updated sql server info to address PR feedback --- content/v2.0/query-data/flux/sql.md | 4 ++-- .../v2.0/reference/flux/stdlib/sql/_index.md | 4 ++-- .../v2.0/reference/flux/stdlib/sql/from.md | 24 ++++++++++++++----- content/v2.0/reference/flux/stdlib/sql/to.md | 24 ++++++++++++++----- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/content/v2.0/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index 74a416c43..a079e4438 100644 --- a/content/v2.0/query-data/flux/sql.md +++ b/content/v2.0/query-data/flux/sql.md @@ -5,7 +5,7 @@ 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, - SQLite, and MS SQL Server. + SQLite, and Microsoft SQL Server. v2.0/tags: [query, flux, sql] menu: v2_0: @@ -32,7 +32,7 @@ The [Flux](/v2.0/reference/flux) `sql` package provides functions for working wi [`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/), [SQLite](https://www.sqlite.org/index.html), -and [MS SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx), +and [Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx), and use the results with InfluxDB dashboards, tasks, and other operations. - [Query a SQL data source](#query-a-sql-data-source) diff --git a/content/v2.0/reference/flux/stdlib/sql/_index.md b/content/v2.0/reference/flux/stdlib/sql/_index.md index 0b393d83d..fd8230e9a 100644 --- a/content/v2.0/reference/flux/stdlib/sql/_index.md +++ b/content/v2.0/reference/flux/stdlib/sql/_index.md @@ -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, Snowflake, SQLite, and MS SQL Server. + as MySQL, PostgreSQL, Snowflake, SQLite, and Microsoft SQL Server. Import the `sql` package. aliases: - /v2.0/reference/flux/functions/sql/ @@ -18,7 +18,7 @@ related: --- SQL Flux functions provide tools for working with data in SQL databases such as -MySQL, PostgreSQL, Snowflake, SQLite, and MS SQL Server. +MySQL, PostgreSQL, Snowflake, SQLite, and Microsoft SQL Server. Import the `sql` package: ```js diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index 432569d76..b8d5f35d4 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -63,7 +63,7 @@ username[:password]@hostname:port/dbname/schemaname?account=¶m # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=ro -# MS SQL Server Driver DSNs +# 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 @@ -163,10 +163,15 @@ sql.from( ``` #### SQL Server ADO authentication -Use one of the the following methods to provide SQL Server authentication credentials as +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 @@ -180,18 +185,25 @@ 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 %}} -``` -azure auth=c:\secure\azure.auth +```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 +##### 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 ``` diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index 7cc25aafc..7fbeb1cca 100644 --- a/content/v2.0/reference/flux/stdlib/sql/to.md +++ b/content/v2.0/reference/flux/stdlib/sql/to.md @@ -62,7 +62,7 @@ username[:password]@hostname:port/dbname/schemaname?account=¶m # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=rw -# MS SQL Server Driver DSNs +# 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 @@ -172,10 +172,15 @@ sql.to( ``` #### SQL Server ADO authentication -Use one of the the following methods to provide SQL Server authentication credentials as +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 @@ -189,18 +194,25 @@ 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 %}} -``` -azure auth=c:\secure\azure.auth +```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 +##### 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 ``` From 1519e49cd0cd71c7a8e2d0bf92f3ad7ac5ac60f7 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 17 Jun 2020 08:30:20 -0600 Subject: [PATCH 05/22] added flux 0.70 placholder release notes --- content/v2.0/reference/release-notes/flux.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index ed3c14153..2a3232091 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -16,6 +16,11 @@ 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 [unreleased] +_placholder_ + +--- + ## v0.69.2 [2020-06-10] ### Bug fixes From 30b01414e6c3ece55868388d1e9cb83a5659fbfe Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 18 Jun 2020 10:40:06 -0600 Subject: [PATCH 06/22] added flux teams package, resolves #1064 --- .../reference/flux/stdlib/contrib/_index.md | 2 +- .../flux/stdlib/contrib/discord/_index.md | 2 +- .../flux/stdlib/contrib/teams/_index.md | 32 ++++++++ .../flux/stdlib/contrib/teams/endpoint.md | 78 +++++++++++++++++++ .../flux/stdlib/contrib/teams/message.md | 78 +++++++++++++++++++ 5 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 content/v2.0/reference/flux/stdlib/contrib/teams/_index.md create mode 100644 content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md create mode 100644 content/v2.0/reference/flux/stdlib/contrib/teams/message.md diff --git a/content/v2.0/reference/flux/stdlib/contrib/_index.md b/content/v2.0/reference/flux/stdlib/contrib/_index.md index 5355284b8..7051d3edb 100644 --- a/content/v2.0/reference/flux/stdlib/contrib/_index.md +++ b/content/v2.0/reference/flux/stdlib/contrib/_index.md @@ -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] diff --git a/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md b/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md index 7bff095dd..ecd131b2e 100644 --- a/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md +++ b/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md @@ -7,7 +7,7 @@ description: > menu: v2_0_ref: name: Discord - parent: User-contributed + parent: Contributed weight: 202 v2.0/tags: [functions, discord, package] --- diff --git a/content/v2.0/reference/flux/stdlib/contrib/teams/_index.md b/content/v2.0/reference/flux/stdlib/contrib/teams/_index.md new file mode 100644 index 000000000..7d8cad01f --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/teams/_index.md @@ -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 %}} diff --git a/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md b/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md new file mode 100644 index 000000000..119312c7d --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md @@ -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 %}} diff --git a/content/v2.0/reference/flux/stdlib/contrib/teams/message.md b/content/v2.0/reference/flux/stdlib/contrib/teams/message.md new file mode 100644 index 000000000..f2a384809 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/teams/message.md @@ -0,0 +1,78 @@ +--- +title: teams.message() function +description: > + The `teams.message()` function sends a single message to a Microsoft Teams channel using + a [incoming webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). +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 %}} From 590703fa1ada90fb2cc7f227465d2136a91ca96a Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 18 Jun 2020 13:25:58 -0600 Subject: [PATCH 07/22] updated teams pkg with PR feedback --- content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md | 2 +- content/v2.0/reference/flux/stdlib/contrib/teams/message.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md b/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md index 119312c7d..2f37e7e25 100644 --- a/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md +++ b/content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md @@ -66,7 +66,7 @@ crit_statuses |> endpoint(mapFn: (r) => ({ title: "Disk Usage" text: "Disk usage is: **${r.status}**.", - summary: "Disk Usage is ${r.status}" + summary: "Disk usage is ${r.status}" }) ) ``` diff --git a/content/v2.0/reference/flux/stdlib/contrib/teams/message.md b/content/v2.0/reference/flux/stdlib/contrib/teams/message.md index f2a384809..e0fc5424c 100644 --- a/content/v2.0/reference/flux/stdlib/contrib/teams/message.md +++ b/content/v2.0/reference/flux/stdlib/contrib/teams/message.md @@ -2,7 +2,7 @@ title: teams.message() function description: > The `teams.message()` function sends a single message to a Microsoft Teams channel using - a [incoming webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). + an [incoming webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). menu: v2_0_ref: name: teams.message @@ -67,7 +67,7 @@ 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}" + summary: "Disk usage is ${lastReported.status}" ) ``` From 41b3434c8995b773dfd9abd661b58aa4f1c846cf Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 10:22:58 -0600 Subject: [PATCH 08/22] added flux telegram package, resolves #1058 --- .../flux/stdlib/contrib/teams/message.md | 2 +- .../flux/stdlib/contrib/telegram/_index.md | 50 ++++++++ .../flux/stdlib/contrib/telegram/endpoint.md | 106 +++++++++++++++++ .../flux/stdlib/contrib/telegram/message.md | 107 ++++++++++++++++++ 4 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 content/v2.0/reference/flux/stdlib/contrib/telegram/_index.md create mode 100644 content/v2.0/reference/flux/stdlib/contrib/telegram/endpoint.md create mode 100644 content/v2.0/reference/flux/stdlib/contrib/telegram/message.md diff --git a/content/v2.0/reference/flux/stdlib/contrib/teams/message.md b/content/v2.0/reference/flux/stdlib/contrib/teams/message.md index e0fc5424c..f56bbc01b 100644 --- a/content/v2.0/reference/flux/stdlib/contrib/teams/message.md +++ b/content/v2.0/reference/flux/stdlib/contrib/teams/message.md @@ -2,7 +2,7 @@ title: teams.message() function description: > The `teams.message()` function sends a single message to a Microsoft Teams channel using - an [incoming webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). + an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). menu: v2_0_ref: name: teams.message diff --git a/content/v2.0/reference/flux/stdlib/contrib/telegram/_index.md b/content/v2.0/reference/flux/stdlib/contrib/telegram/_index.md new file mode 100644 index 000000000..6c2d2171a --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/telegram/_index.md @@ -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 %}} diff --git a/content/v2.0/reference/flux/stdlib/contrib/telegram/endpoint.md b/content/v2.0/reference/flux/stdlib/contrib/telegram/endpoint.md new file mode 100644 index 000000000..4e5736adb --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/telegram/endpoint.md @@ -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 +Required +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 %}} diff --git a/content/v2.0/reference/flux/stdlib/contrib/telegram/message.md b/content/v2.0/reference/flux/stdlib/contrib/telegram/message.md new file mode 100644 index 000000000..e9e074f91 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/telegram/message.md @@ -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 +Required +Telegram bot token. + +_**Data type:** String_ + +### channel +Required +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 %}} From b21df957bf478a4c0973daf073e1e1a632c423a0 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 12:43:25 -0600 Subject: [PATCH 09/22] added aws athena support to sql pkg, resolves #1078 --- content/v2.0/query-data/flux/sql.md | 7 +-- .../v2.0/reference/flux/stdlib/sql/_index.md | 13 +++-- .../v2.0/reference/flux/stdlib/sql/from.md | 47 ++++++++++++++++++- content/v2.0/reference/flux/stdlib/sql/to.md | 11 +++++ 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/content/v2.0/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index a079e4438..b7b4d9e0d 100644 --- a/content/v2.0/query-data/flux/sql.md +++ b/content/v2.0/query-data/flux/sql.md @@ -5,7 +5,7 @@ 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, - SQLite, and Microsoft SQL Server. + SQLite, Microsoft SQL Server, Amazon Athena. v2.0/tags: [query, flux, sql] menu: v2_0: @@ -32,8 +32,9 @@ The [Flux](/v2.0/reference/flux) `sql` package provides functions for working wi [`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/), [SQLite](https://www.sqlite.org/index.html), -and [Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx), -and use the results with InfluxDB dashboards, tasks, and other operations. +[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) diff --git a/content/v2.0/reference/flux/stdlib/sql/_index.md b/content/v2.0/reference/flux/stdlib/sql/_index.md index fd8230e9a..53dadf6c5 100644 --- a/content/v2.0/reference/flux/stdlib/sql/_index.md +++ b/content/v2.0/reference/flux/stdlib/sql/_index.md @@ -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, Snowflake, SQLite, and Microsoft SQL Server. + 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, SQLite, and Microsoft SQL Server. +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 diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index b8d5f35d4..f48d16a92 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -35,6 +35,7 @@ _**Data type:** String_ The following drivers are available: +- awsathena - mysql - postgres - snowflake @@ -49,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 @@ -77,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. @@ -147,6 +159,37 @@ sql.from( ) ``` +### 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): + +\* Required + +- **region** - AWS region \* +- **accessID** - AWS IAM access ID \* +- **secretAccessKey** - AWS IAM secret key \* +- **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" diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index 7fbeb1cca..0dc69b006 100644 --- a/content/v2.0/reference/flux/stdlib/sql/to.md +++ b/content/v2.0/reference/flux/stdlib/sql/to.md @@ -86,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. @@ -216,3 +222,8 @@ _For information about managed identities, see [Microsoft managed identities](ht ``` 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 %}} From 86fb65b0b11d263ec6bb313e462a7b549af94ce8 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 14:01:08 -0600 Subject: [PATCH 10/22] added warning to group fn about sort order, closes #1129 --- .../flux/stdlib/built-in/transformations/group.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md index 77fc61f9c..0af36fcff 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md @@ -32,6 +32,13 @@ 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()`. +{{% /warn %}} + ## Parameters ### columns From 84daa2ec0b3e2cf83bf8e806f0a177cb47ed9368 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 14:07:31 -0600 Subject: [PATCH 11/22] add example to group sort warning --- .../reference/flux/stdlib/built-in/transformations/group.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md index 0af36fcff..abb897cad 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md @@ -37,6 +37,12 @@ group() `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 From b42c464166d81f5ba55c381bdebce07a59ca3977 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 14:49:30 -0600 Subject: [PATCH 12/22] moved derivative and difference out of aggregate functions, resolves #1059 --- content/v2.0/query-data/flux/rate.md | 2 +- .../transformations/{aggregates => }/derivative.md | 11 ++++++++--- .../transformations/{aggregates => }/difference.md | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/derivative.md (84%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/difference.md (90%) diff --git a/content/v2.0/query-data/flux/rate.md b/content/v2.0/query-data/flux/rate.md index fb1a5825b..ec1535cd4 100644 --- a/content/v2.0/query-data/flux/rate.md +++ b/content/v2.0/query-data/flux/rate.md @@ -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 --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/derivative.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md similarity index 84% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/derivative.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md index 8594c0310..21a161c62 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/derivative.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md @@ -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 @@ -30,6 +32,9 @@ derivative( ) ``` +#### Output tables +For each input table with `n` rows, `derivative()` outputs a table with `n - 1` rows. + ## Parameters ### unit diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/difference.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md similarity index 90% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/difference.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md index fb773a363..9f5e6c903 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/difference.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md @@ -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 @@ -27,6 +29,9 @@ difference( ) ``` +#### Output tables +For each input table with `n` rows, `difference()` outputs a table with `n - 1` rows. + ## Parameters ### nonNegative From 9b46c28e49d440376d8fa7fab264fa57974ef9a2 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 15:57:32 -0600 Subject: [PATCH 13/22] reorganize aggregate transformations to accurately repsresent true aggregates --- content/v2.0/query-data/flux/increase.md | 4 ++-- .../transformations/aggregates/_index.md | 12 ++++++---- .../chandemomentumoscillator.md | 17 ++++++++++--- .../transformations/{aggregates => }/cov.md | 7 +++--- .../{aggregates => }/covariance.md | 7 +++--- .../built-in/transformations/derivative.md | 6 ++--- .../built-in/transformations/difference.md | 5 ++-- .../{aggregates => }/doubleema.md | 15 ++++++------ .../exponentialmovingaverage.md | 13 +++++----- .../{aggregates => }/holtwinters.md | 7 +++--- .../{aggregates => }/increase.md | 17 +++++++++---- .../{aggregates => }/kaufmansama.md | 9 +++---- .../{aggregates => }/kaufmanser.md | 9 +++---- .../{aggregates => }/movingaverage.md | 15 ++++++------ .../{aggregates => }/pearsonr.md | 7 +++--- .../{aggregates => }/relativestrengthindex.md | 24 +++++++++++++------ .../{aggregates => }/timedmovingaverage.md | 15 ++++++------ .../{aggregates => }/tripleema.md | 15 ++++++------ .../tripleexponentialderivative.md | 17 ++++++------- 19 files changed, 132 insertions(+), 89 deletions(-) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/chandemomentumoscillator.md (85%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/cov.md (90%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/covariance.md (86%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/doubleema.md (83%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/exponentialmovingaverage.md (84%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/holtwinters.md (95%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/increase.md (80%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/kaufmansama.md (87%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/kaufmanser.md (86%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/movingaverage.md (77%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/pearsonr.md (89%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/relativestrengthindex.md (82%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/timedmovingaverage.md (82%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/tripleema.md (85%) rename content/v2.0/reference/flux/stdlib/built-in/transformations/{aggregates => }/tripleexponentialderivative.md (83%) diff --git a/content/v2.0/query-data/flux/increase.md b/content/v2.0/query-data/flux/increase.md index 35971ebe1..b84cb1f54 100644 --- a/content/v2.0/query-data/flux/increase.md +++ b/content/v2.0/query-data/flux/increase.md @@ -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. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md index 30f6441f4..fea978837 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md @@ -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 tables 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. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator.md similarity index 85% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator.md index e3e03218a..80a28bf23 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/chandemomentumoscillator.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/chandemomentumoscillator.md @@ -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 >}} diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/cov.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/cov.md similarity index 90% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/cov.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/cov.md index af138115a..6cf522572 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/cov.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/cov.md @@ -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 diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/covariance.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/covariance.md similarity index 86% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/covariance.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/covariance.md index f4e7ecbbc..7760f859b 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/covariance.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/covariance.md @@ -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 diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md index 21a161c62..4b3a4c54d 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md @@ -32,9 +32,6 @@ derivative( ) ``` -#### Output tables -For each input table with `n` rows, `derivative()` outputs a table with `n - 1` rows. - ## Parameters ### unit @@ -61,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") diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md index 9f5e6c903..62948590f 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md @@ -29,9 +29,6 @@ difference( ) ``` -#### Output tables -For each input table with `n` rows, `difference()` outputs a table with `n - 1` rows. - ## Parameters ### nonNegative @@ -60,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 diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/doubleema.md similarity index 83% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/doubleema.md index 54799e1e1..edf424696 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/doubleema.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/doubleema.md @@ -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) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage.md similarity index 84% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage.md index 960768f25..cbd7d8b32 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/exponentialmovingaverage.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/exponentialmovingaverage.md @@ -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() --- diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/holtwinters.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/holtwinters.md similarity index 95% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/holtwinters.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/holtwinters.md index 7ad44ac11..75e855131 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/holtwinters.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/holtwinters.md @@ -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 diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/increase.md similarity index 80% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/increase.md index c1eba9af5..1481b6737 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/increase.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/increase.md @@ -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 diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/kaufmansama.md similarity index 87% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/kaufmansama.md index 2d76e185d..fcc99a883 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmansama.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/kaufmansama.md @@ -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( diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/kaufmanser.md similarity index 86% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/kaufmanser.md index cac7b51c2..87787238d 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/kaufmanser.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/kaufmanser.md @@ -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) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/movingaverage.md similarity index 77% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/movingaverage.md index cd8f97020..1fe3130ca 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/movingaverage.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/movingaverage.md @@ -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) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/pearsonr.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/pearsonr.md similarity index 89% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/pearsonr.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/pearsonr.md index f5e4bc776..c3ac9d936 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/pearsonr.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/pearsonr.md @@ -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 diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/relativestrengthindex.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/relativestrengthindex.md similarity index 82% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/relativestrengthindex.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/relativestrengthindex.md index 58a8cb856..42998011c 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/relativestrengthindex.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/relativestrengthindex.md @@ -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 >}} diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage.md similarity index 82% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage.md index 2d1b0be01..e65913828 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/timedmovingaverage.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/timedmovingaverage.md @@ -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( diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/tripleema.md similarity index 85% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/tripleema.md index 140882c33..9810b3316 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleema.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/tripleema.md @@ -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) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleexponentialderivative.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative.md similarity index 83% rename from content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleexponentialderivative.md rename to content/v2.0/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative.md index 9d6aee924..1ac8d5bc3 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/tripleexponentialderivative.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/tripleexponentialderivative.md @@ -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) From ec3e1f8ea336c4cc1cbb73517c13b2671101fc17 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 22 Jun 2020 16:02:01 -0600 Subject: [PATCH 14/22] typo fix in aggregate fn landing page --- .../flux/stdlib/built-in/transformations/aggregates/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md index fea978837..0a9435059 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md @@ -18,7 +18,7 @@ related: - /v2.0/query-data/flux/window-aggregate/ --- -Flux's built-in aggregate transformations take values from an input tables and aggregate them in some way. +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. From 0f09dd6b1fe50dc3ced1687b9276a6051cc82980 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 04:56:50 -0600 Subject: [PATCH 15/22] updated sql athena changes to address PR feedback --- content/v2.0/query-data/flux/sql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index b7b4d9e0d..850d0a074 100644 --- a/content/v2.0/query-data/flux/sql.md +++ b/content/v2.0/query-data/flux/sql.md @@ -5,7 +5,7 @@ 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, - SQLite, Microsoft SQL Server, Amazon Athena. + SQLite, Microsoft SQL Server, and Amazon Athena. v2.0/tags: [query, flux, sql] menu: v2_0: From 49eade32800fd665d3c2bc491b09e3379729f68b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 05:26:19 -0600 Subject: [PATCH 16/22] update date.truncate with support for duration values --- .../reference/flux/stdlib/date/truncate.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/stdlib/date/truncate.md b/content/v2.0/reference/flux/stdlib/date/truncate.md index 762cfffcd..318b3a3ce 100644 --- a/content/v2.0/reference/flux/stdlib/date/truncate.md +++ b/content/v2.0/reference/flux/stdlib/date/truncate.md @@ -31,7 +31,7 @@ date.truncate( ### t The time to operate on. -_**Data type:** Time_ +_**Data type:** Time | Duration_ ### unit The unit of time to truncate to. @@ -44,6 +44,8 @@ For example: `1s`, `1m`, `1h`. {{% /note %}} ## Examples + +##### Truncate time values ```js import "date" @@ -57,3 +59,20 @@ 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:00Z + +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 + +``` From 53662578153eab0a2bb7c4681486bfaa23a39f47 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 05:30:19 -0600 Subject: [PATCH 17/22] removed unnecessary newlines from data.truncate examples --- content/v2.0/reference/flux/stdlib/date/truncate.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/date/truncate.md b/content/v2.0/reference/flux/stdlib/date/truncate.md index 318b3a3ce..e4805a24e 100644 --- a/content/v2.0/reference/flux/stdlib/date/truncate.md +++ b/content/v2.0/reference/flux/stdlib/date/truncate.md @@ -57,7 +57,6 @@ date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1m) date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1h) // Returns 2019-06-03T13:00:00.000000000Z - ``` ##### Truncate time values using durations @@ -74,5 +73,4 @@ date.truncate(t: -1m, unit: 1m) date.truncate(t: -1h, unit: 1h) // Returns 2019-12-31T23:00:00.000000000Z - ``` From 5a384deafb3055ca7ba317e6aef967c8f25aa333 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 11:41:23 -0600 Subject: [PATCH 18/22] updated now time in date.truncate duration examples --- content/v2.0/reference/flux/stdlib/date/truncate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/stdlib/date/truncate.md b/content/v2.0/reference/flux/stdlib/date/truncate.md index e4805a24e..9263d50b1 100644 --- a/content/v2.0/reference/flux/stdlib/date/truncate.md +++ b/content/v2.0/reference/flux/stdlib/date/truncate.md @@ -63,7 +63,7 @@ date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1h) ```js import "date" -option now = () => 2020-01-01T00:00:00Z +option now = () => 2020-01-01T00:00:30.500000000Z date.truncate(t: -30s, unit: 1s) // Returns 2019-12-31T23:59:30.000000000Z From a548088634a62384b3676b1ab46787f2011a82b7 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 11:44:03 -0600 Subject: [PATCH 19/22] updated description of t param in date.truncate --- content/v2.0/reference/flux/stdlib/date/truncate.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/v2.0/reference/flux/stdlib/date/truncate.md b/content/v2.0/reference/flux/stdlib/date/truncate.md index 9263d50b1..43645f815 100644 --- a/content/v2.0/reference/flux/stdlib/date/truncate.md +++ b/content/v2.0/reference/flux/stdlib/date/truncate.md @@ -30,6 +30,8 @@ date.truncate( ### t The time to operate on. +Use an absolute time or relative duration. +Durations are relative to `now()`. _**Data type:** Time | Duration_ From 40f4ed3a3c6e9d0b27e70fb26815dd22e6b54b2b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 14:11:22 -0600 Subject: [PATCH 20/22] updated other date pkg functions with durations and examples --- .../flux/stdlib/built-in/misc/now.md | 12 ++++++++- .../v2.0/reference/flux/stdlib/date/hour.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/microsecond.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/millisecond.md | 26 ++++++++++++++++++- .../v2.0/reference/flux/stdlib/date/month.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/monthday.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/nanosecond.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/quarter.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/truncate.md | 18 ++++++------- .../reference/flux/stdlib/date/weekday.md | 26 ++++++++++++++++++- .../v2.0/reference/flux/stdlib/date/year.md | 26 ++++++++++++++++++- .../reference/flux/stdlib/date/yearday.md | 26 ++++++++++++++++++- 12 files changed, 270 insertions(+), 20 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/built-in/misc/now.md b/content/v2.0/reference/flux/stdlib/built-in/misc/now.md index bcc5048c8..3b38aaf35 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/misc/now.md +++ b/content/v2.0/reference/flux/stdlib/built-in/misc/now.md @@ -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. diff --git a/content/v2.0/reference/flux/stdlib/date/hour.md b/content/v2.0/reference/flux/stdlib/date/hour.md index efdf143e7..02bde42e7 100644 --- a/content/v2.0/reference/flux/stdlib/date/hour.md +++ b/content/v2.0/reference/flux/stdlib/date/hour.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/microsecond.md b/content/v2.0/reference/flux/stdlib/date/microsecond.md index bd4cbba76..3b6def9d0 100644 --- a/content/v2.0/reference/flux/stdlib/date/microsecond.md +++ b/content/v2.0/reference/flux/stdlib/date/microsecond.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/millisecond.md b/content/v2.0/reference/flux/stdlib/date/millisecond.md index 6d7a6285e..31496d092 100644 --- a/content/v2.0/reference/flux/stdlib/date/millisecond.md +++ b/content/v2.0/reference/flux/stdlib/date/millisecond.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/month.md b/content/v2.0/reference/flux/stdlib/date/month.md index 6612dedd4..01330e261 100644 --- a/content/v2.0/reference/flux/stdlib/date/month.md +++ b/content/v2.0/reference/flux/stdlib/date/month.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/monthday.md b/content/v2.0/reference/flux/stdlib/date/monthday.md index fabc7d31b..36684343f 100644 --- a/content/v2.0/reference/flux/stdlib/date/monthday.md +++ b/content/v2.0/reference/flux/stdlib/date/monthday.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/nanosecond.md b/content/v2.0/reference/flux/stdlib/date/nanosecond.md index 9d05b1f72..846aa0129 100644 --- a/content/v2.0/reference/flux/stdlib/date/nanosecond.md +++ b/content/v2.0/reference/flux/stdlib/date/nanosecond.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/quarter.md b/content/v2.0/reference/flux/stdlib/date/quarter.md index a2f05b0f9..5a225a4a9 100644 --- a/content/v2.0/reference/flux/stdlib/date/quarter.md +++ b/content/v2.0/reference/flux/stdlib/date/quarter.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/truncate.md b/content/v2.0/reference/flux/stdlib/date/truncate.md index 43645f815..f2ef1cb3b 100644 --- a/content/v2.0/reference/flux/stdlib/date/truncate.md +++ b/content/v2.0/reference/flux/stdlib/date/truncate.md @@ -51,14 +51,14 @@ For example: `1s`, `1m`, `1h`. ```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: 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: 1h) +// Returns 2019-06-03T13:00:00.000000000Z ``` ##### Truncate time values using durations @@ -68,11 +68,11 @@ import "date" option now = () => 2020-01-01T00:00:30.500000000Z date.truncate(t: -30s, unit: 1s) -// Returns 2019-12-31T23:59:30.000000000Z +// Returns 2019-12-31T23:59:30.000000000Z date.truncate(t: -1m, unit: 1m) -// Returns 2019-12-31T23:59:00.000000000Z +// Returns 2019-12-31T23:59:00.000000000Z date.truncate(t: -1h, unit: 1h) -// Returns 2019-12-31T23:00:00.000000000Z +// Returns 2019-12-31T23:00:00.000000000Z ``` diff --git a/content/v2.0/reference/flux/stdlib/date/weekday.md b/content/v2.0/reference/flux/stdlib/date/weekday.md index 6e6fdb18c..0afcf7c67 100644 --- a/content/v2.0/reference/flux/stdlib/date/weekday.md +++ b/content/v2.0/reference/flux/stdlib/date/weekday.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/year.md b/content/v2.0/reference/flux/stdlib/date/year.md index f911a5976..fd452ed2f 100644 --- a/content/v2.0/reference/flux/stdlib/date/year.md +++ b/content/v2.0/reference/flux/stdlib/date/year.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/yearday.md b/content/v2.0/reference/flux/stdlib/date/yearday.md index 20df57afe..a7ff048fb 100644 --- a/content/v2.0/reference/flux/stdlib/date/yearday.md +++ b/content/v2.0/reference/flux/stdlib/date/yearday.md @@ -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 +``` From 71a2903bd60977e0248de9e309308edc05f92880 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 24 Jun 2020 15:51:28 -0600 Subject: [PATCH 21/22] added duration support and examples to more data functions --- .../v2.0/reference/flux/stdlib/date/minute.md | 26 ++++++++++++++++++- .../v2.0/reference/flux/stdlib/date/second.md | 26 ++++++++++++++++++- .../v2.0/reference/flux/stdlib/date/week.md | 26 ++++++++++++++++++- 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/date/minute.md b/content/v2.0/reference/flux/stdlib/date/minute.md index 5e5ec0b34..d1e9db92c 100644 --- a/content/v2.0/reference/flux/stdlib/date/minute.md +++ b/content/v2.0/reference/flux/stdlib/date/minute.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/second.md b/content/v2.0/reference/flux/stdlib/date/second.md index e7cc28f7f..33493d457 100644 --- a/content/v2.0/reference/flux/stdlib/date/second.md +++ b/content/v2.0/reference/flux/stdlib/date/second.md @@ -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 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/week.md b/content/v2.0/reference/flux/stdlib/date/week.md index dec8bddec..d508e7c10 100644 --- a/content/v2.0/reference/flux/stdlib/date/week.md +++ b/content/v2.0/reference/flux/stdlib/date/week.md @@ -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 +``` From e22dff45943fe3e555d7f74ef104b584811e7872 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 29 Jun 2020 13:52:54 -0600 Subject: [PATCH 22/22] added flux-0.70 release notes --- content/v2.0/reference/release-notes/flux.md | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index 2a3232091..4bd6fd2d2 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -16,8 +16,25 @@ 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 [unreleased] -_placholder_ +## 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`. ---