diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 420812f3f..d22beba73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -546,6 +546,18 @@ The following options are available: - third - quarter +### Tooltips +Use the `{{< tooltips >}}` shortcode to add tooltips to text. +The **1st** argument is the text shown in the tooltip. +The **2nd** argument is the highlighted text that triggers the tooltip. + +```md +I like {{< tooltip "Butterflies are awesome!" "butterflies" >}}. +``` + +The example above renders as "I like butterflies" with "butterflies" highlighted. +When you hover over "butterflies," a tooltip appears with the text: "Butterflies are awesome!" + ### Reference content The InfluxDB documentation is "task-based," meaning content primarily focuses on what a user is **doing**, not what they are **using**. diff --git a/assets/js/influxdb-url.js b/assets/js/influxdb-url.js index 7d9e6c4fb..955181d59 100644 --- a/assets/js/influxdb-url.js +++ b/assets/js/influxdb-url.js @@ -58,7 +58,18 @@ function storeUrl(newUrl, prevUrl) { Cookies.set('influxdb_url', newUrl) } -// Preserver URLs in codeblocks that come just after or are inside a div +// Store custom URL session cookie – influxdb_custom_url +function storeCustomUrl(customUrl) { + Cookies.set('influxdb_custom_url', customUrl) + $('input#custom[type=radio]').val(customUrl) +} + +// Remove custom URL session cookie – influxdb_custom_url +function removeCustomUrl() { + Cookies.remove('influxdb_custom_url') +} + +// Preserve URLs in codeblocks that come just after or are inside a div // with the class, .keep-url function addPreserve() { $('.keep-url').each(function () { @@ -88,9 +99,6 @@ updateUrls(defaultUrl, getUrl()) // Append URL selector buttons to code blocks appendUrlSelector(getUrl()) -// Set active radio button on page load -setRadioButton(getUrl()) - // Update URLs whenever you focus on the browser tab $(window).focus(function() { updateUrls(getPrevUrl(), getUrl()) @@ -115,3 +123,51 @@ $('button.url-trigger, #callout-url-selector .close').click(function() { $('#callout-url-selector').fadeOut(200) } }) + +///////////////////////////////// CUSTOM URLs ///////////////////////////////// + +// Trigger radio button on custom URL field focus +$('input#custom-url-field').focus(function(e) { + $('input#custom[type="radio"]').trigger('click') +}) + +$("#custom-url").submit(function(e) { + e.preventDefault(); + $('#modal-close').trigger('click') +}); + +// Store the custom InfluxDB URL when exiting the field +$('#custom-url-field').blur(function() { + custUrl = $(this).val() + if (custUrl.length > 0 ) { + storeCustomUrl(custUrl) + updateUrls(getUrl(), custUrl) + storeUrl(custUrl, getPrevUrl()) + } else { + $('input#custom').val('http://example.com:8080') + removeCustomUrl(); + $('input[name="influxdb-loc"][value="' + defaultUrl + '"]').trigger('click') + } +}) + +// Populate the custom InfluxDB URL field on page load +if ( Cookies.get('influxdb_custom_url') != undefined ) { + $('input#custom').val(Cookies.get('influxdb_custom_url')) + $('#custom-url-field').val(Cookies.get('influxdb_custom_url')) +} + +// Set active radio button on page load +setRadioButton(getUrl()) + +/////////////////////////// Dynamically update URLs /////////////////////////// + +// Extract the protocol and hostname of referrer +referrerHost = document.referrer.match(/^(?:[^\/]*\/){2}[^\/]+/g)[0] + +// Check if the referrerHost is one of the cloud URLs +// cloudUrls is built dynamically in layouts/partials/footer/javascript.html +if (cloudUrls.includes(referrerHost)) { + storeUrl(referrerHost, getUrl()) + updateUrls(getPrevUrl(), referrerHost) + setRadioButton(referrerHost) +} diff --git a/assets/styles/layouts/_cloud-selector.scss b/assets/styles/layouts/_url-selector.scss similarity index 82% rename from assets/styles/layouts/_cloud-selector.scss rename to assets/styles/layouts/_url-selector.scss index f6e5d8ff7..e3d7bd521 100644 --- a/assets/styles/layouts/_cloud-selector.scss +++ b/assets/styles/layouts/_url-selector.scss @@ -136,6 +136,42 @@ } } + li.custom { + display: flex; + align-items: center; + } + #custom-url { + display: inline-block; + width: 100%; + padding-left: .5rem; + input { + &#custom-url-field { + font-family: $rubik; + font-weight: $medium; + background: $modal-field-bg; + border-radius: $radius; + border: 1px solid $sidebar-search-bg; + padding: .5em; + width: 100%; + color: $sidebar-search-text; + transition-property: border, box-shadow; + transition-duration: .2s; + box-shadow: 2px 2px 6px $sidebar-search-shadow; + &:focus { + outline: none; + border-color: $sidebar-search-highlight; + box-shadow: 1px 1px 10px rgba($sidebar-search-highlight, .5); + border-radius: $radius; + } + &::placeholder { + color: rgba($sidebar-search-text, .45); + font-weight: normal; + font-style: italic; + } + } + } + } + .radio { position: relative; display: inline-block; diff --git a/assets/styles/styles-default.scss b/assets/styles/styles-default.scss index 97fd6d5cd..46f68bf40 100644 --- a/assets/styles/styles-default.scss +++ b/assets/styles/styles-default.scss @@ -22,5 +22,5 @@ "layouts/algolia-search-overrides", "layouts/landing", "layouts/error-page", - "layouts/cloud-selector", + "layouts/url-selector", "layouts/feature-callouts"; diff --git a/assets/styles/themes/_theme-dark.scss b/assets/styles/themes/_theme-dark.scss index d4e35d921..d91f8ce91 100644 --- a/assets/styles/themes/_theme-dark.scss +++ b/assets/styles/themes/_theme-dark.scss @@ -182,6 +182,9 @@ $tooltip-color-alt: $br-chartreuse; $tooltip-bg: $br-chartreuse; $tooltip-text: $g2-kevlar; +// URL Modal colors +$modal-field-bg: $g1-raven; + // SVG colors $svg-table-header: $g6-smoke; $svg-table-stroke: $g0-obsidian; diff --git a/assets/styles/themes/_theme-light.scss b/assets/styles/themes/_theme-light.scss index eb3962855..ade4a6283 100644 --- a/assets/styles/themes/_theme-light.scss +++ b/assets/styles/themes/_theme-light.scss @@ -182,6 +182,9 @@ $tooltip-color-alt: $p-twilight !default; $tooltip-bg: $p-amethyst !default; $tooltip-text: $g20-white !default; +// URL Modal colors +$modal-field-bg: $g20-white !default; + // SVG colors $svg-table-header: $g15-platinum !default; $svg-table-stroke: $g7-graphite !default; diff --git a/content/v2.0/get-started.md b/content/v2.0/get-started.md index 4c74b829a..4053aa254 100644 --- a/content/v2.0/get-started.md +++ b/content/v2.0/get-started.md @@ -572,7 +572,7 @@ and [Manually update Telegraf configurations](/v2.0/write-data/use-telegraf/manu #### Scrape data **InfluxDB OSS** lets you scrape Prometheus-formatted metrics from HTTP endpoints. -For details, see [Scrape data](/v2.0/write-data/scrape-data/). +For details, see [Scrape data](/v2.0/write-data/no-code/scrape-data/). #### API, CLI, and client libraries @@ -607,7 +607,7 @@ See [Monitor and alert](/v2.0/monitor-alert/). {{< cloud-name >}} is API-compatible and functionally compatible with InfluxDB OSS 2.0. The primary differences between InfluxDB OSS 2.0 and InfluxDB Cloud 2.0 are: -- [InfluxDB scrapers](/v2.0/write-data/scrape-data/) that collect data from specified +- [InfluxDB scrapers](/v2.0/write-data/no-code/scrape-data/) that collect data from specified targets are not available in {{< cloud-name "short" >}}. - {{< cloud-name "short" >}} instances are currently limited to a single organization. diff --git a/content/v2.0/influxdb-templates/create.md b/content/v2.0/influxdb-templates/create.md index 83a65c16b..658bff54a 100644 --- a/content/v2.0/influxdb-templates/create.md +++ b/content/v2.0/influxdb-templates/create.md @@ -50,11 +50,6 @@ In **InfluxDB Cloud**, your user account is an organization. 4. Export the template _(see [below](#export-a-template))_. -{{% warn %}} -InfluxDB templates do not support the [table visualization type](/v2.0/visualize-data/visualization-types/table/). -Dashboard cells that use table visualization are not included in exported templates. -{{% /warn %}} - ## Export a template Do one of the following to export a template: diff --git a/content/v2.0/organizations/buckets/view-buckets.md b/content/v2.0/organizations/buckets/view-buckets.md index b0d001b00..9d7eb0e54 100644 --- a/content/v2.0/organizations/buckets/view-buckets.md +++ b/content/v2.0/organizations/buckets/view-buckets.md @@ -9,15 +9,20 @@ menu: weight: 202 --- -## View buckets in the InfluxDB UI +## View a list of buckets + +### View buckets in the InfluxDB UI 1. In the navigation menu on the left, select **Data (Load Data)** > **Buckets**. {{< nav-icon "data" >}} -2. Click a bucket to open it **Data Explorer**. + A list of buckets with their retention policies and IDs appears. -## View buckets using the influx CLI +2. Click a bucket to open it in the **Data Explorer**. +3. Click the bucket ID to copy it to the clipboard. + +### View buckets using the influx CLI Use the [`influx bucket list` command](/v2.0/reference/cli/influx/bucket/list) to view a buckets in an organization. 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/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/query-data/flux/sql.md b/content/v2.0/query-data/flux/sql.md index 6baee5ac5..850d0a074 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, Microsoft SQL Server, and Amazon Athena. v2.0/tags: [query, flux, sql] menu: v2_0: @@ -30,8 +31,10 @@ list_code_example: | The [Flux](/v2.0/reference/flux) `sql` package provides functions for working with SQL data sources. [`sql.from()`](/v2.0/reference/flux/stdlib/sql/from/) lets you query SQL data sources like [PostgreSQL](https://www.postgresql.org/), [MySQL](https://www.mysql.com/), -[Snowflake](https://www.snowflake.com/), and [SQLite](https://www.sqlite.org/index.html), -and use the results with InfluxDB dashboards, tasks, and other operations. +[Snowflake](https://www.snowflake.com/), [SQLite](https://www.sqlite.org/index.html), +[Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx), +and [Amazon Athena](https://aws.amazon.com/athena/) and use the results with +InfluxDB dashboards, tasks, and other operations. - [Query a SQL data source](#query-a-sql-data-source) - [Join SQL data with data in InfluxDB](#join-sql-data-with-data-in-influxdb) @@ -57,6 +60,7 @@ To query a SQL data source: [MySQL](#) [Snowflake](#) [SQLite](#) +[SQL Server](#) {{% /code-tabs %}} {{% code-tab-content %}} @@ -110,6 +114,21 @@ sql.from( ) ``` {{% /code-tab-content %}} + +{{% code-tab-content %}} +```js +import "sql" + +sql.from( + driverName: "sqlserver", + dataSourceName: "sqlserver://user:password@localhost:1234?database=examplebdb", + query: "GO SELECT * FROM Example.Table" +) +``` + +_For information about authenticating with SQL Server using ADO-style parameters, +see [SQL Server ADO authentication](/v2.0/reference/flux/stdlib/sql/from/#sql-server-ado-authentication)._ +{{% /code-tab-content %}} {{< /code-tabs-wrapper >}} _See the [`sql.from()` documentation](/v2.0/reference/flux/stdlib/sql/from/) for diff --git a/content/v2.0/query-data/optimize-queries.md b/content/v2.0/query-data/optimize-queries.md index 6a5e3226d..baacd1897 100644 --- a/content/v2.0/query-data/optimize-queries.md +++ b/content/v2.0/query-data/optimize-queries.md @@ -27,6 +27,10 @@ reduce the amount of memory necessary to run a query. - [range()](/v2.0/reference/flux/stdlib/built-in/transformations/range/) - [filter()](/v2.0/reference/flux/stdlib/built-in/transformations/filter/) - [group()](/v2.0/reference/flux/stdlib/built-in/transformations/group/) +- [count()](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count/) +- [sum()](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/sum/) +- [first()](/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first/) +- [last()](/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last/) Use pushdown functions at the beginning of your query. Once a non-pushdown function runs, Flux pulls data into memory and runs all diff --git a/content/v2.0/reference/cli/influx/transpile/_index.md b/content/v2.0/reference/cli/influx/transpile/_index.md index 4e7d94de0..5820b0d9c 100644 --- a/content/v2.0/reference/cli/influx/transpile/_index.md +++ b/content/v2.0/reference/cli/influx/transpile/_index.md @@ -19,8 +19,23 @@ and includes absolute time ranges using the provided `--now` time. influx transpile [InfluxQL query] [flags] ``` +{{% note %}} +The InfluxQL query must be valid and contain both a database and measurement. +See the [InfluxQL documentation](https://docs.influxdata.com/influxdb/latest/query_language/) for more information. +{{% /note %}} + ## Flags | Flag | | Description | |:---- |:--- |:----------- | | `-h` | `--help` | Help for the `transpile` command | | | `--now` | RFC3339Nano timestamp to use as `now()` time (default is current UTC time) | + +## Examples +```sh +## Transpile an InfluxQL query that specifies the database, +## retention policy, and measurement. +influx transpile 'SELECT example-field FROM db.rp.measurement' + +## Transpile InfluxQL query using default retention policy +influx transpile 'SELECT example-field FROM db..measurement' +``` 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/built-in/transformations/aggregates/_index.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/_index.md index 30f6441f4..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 @@ -1,7 +1,9 @@ --- -title: Flux built-in aggregate functions -list_title: Built-in aggregate functions -description: Flux's built-in aggregate functions take values from an input table and aggregate them in some way. +title: Flux built-in aggregate transformations +list_title: Built-in aggregate transformations +description: > + Flux's aggregate transformations take values from an input table and aggregate them in some way. + Output tables contain a single row with the aggregated value. aliases: - /v2.0/reference/flux/functions/transformations/aggregates - /v2.0/reference/flux/functions/built-in/transformations/aggregates/ @@ -16,8 +18,8 @@ related: - /v2.0/query-data/flux/window-aggregate/ --- -Flux's built-in aggregate functions take values from an input table and aggregate them in some way. -The output table contains a single row with the aggregated value. +Flux's built-in aggregate transformations take values from an input table and aggregate them in some way. +Output tables contain a single row with the aggregated value. Aggregate operations output a table for every input table they receive. You must provide a column to aggregate. diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count.md index 856079ef2..f2262f02f 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count.md @@ -24,7 +24,7 @@ count(column: "_value") ``` {{% note %}} -#### Count empty tables +#### Empty tables `count()` returns `0` for empty tables. To keep empty tables in your data, set the following parameters for the following functions: diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode.md index c07992cf5..9e4ff1d68 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode.md @@ -27,6 +27,11 @@ If there are multiple modes, it returns all of them in a sorted table. Mode only considers non-null values. If there is no mode, `mode()` returns `null`. +{{% warn %}} +#### Empty tables +`mode()` drops empty tables. +{{% /warn %}} + ##### Supported data types - String 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/aggregates/derivative.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/derivative.md similarity index 73% 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..9c912f5bb 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,13 +20,13 @@ 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 derivative( unit: 1s, - nonNegative: false, + nonNegative: true, columns: ["_value"], timeSrc: "_time" ) @@ -39,8 +41,9 @@ Defaults to `1s`. _**Data type:** Duration_ ### nonNegative -Indicates if the derivative is allowed to be negative. -When set to `true`, if a value is less than the previous value, it is assumed the previous value should have been a zero. +Indicates if the derivative is allowed to be negative. Default is `true`. +When `true`, if a value is less than the previous value, it is assumed the +previous value should have been a zero. _**Data type:** Boolean_ @@ -56,6 +59,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/aggregates/difference.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/difference.md similarity index 91% 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..62948590f 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 @@ -55,6 +57,8 @@ _**Data type:** Boolean_ - Some value `v` minus `null` is `v` minus the last non-null value seen before `v`; or `null` if `v` is the first non-null value seen. +## Output tables +For each input table with `n` rows, `difference()` outputs a table with `n - 1` rows. ## Examples 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/group.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/group.md index 77fc61f9c..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 @@ -32,6 +32,19 @@ group(columns: ["_time"], mode:"except") group() ``` +{{% warn %}} +#### Group does not guarantee sort order +`group()` does not guarantee the sort order of output records. +To ensure data is sorted correctly, use [`sort()`](/v2.0/reference/flux/stdlib/built-in/transformations/sort/) +after `group()`. + +```js +data + |> group() + |> sort(columns: ["_time"]) +``` +{{% /warn %}} + ## Parameters ### columns 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/selectors/bottom.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/bottom.md index feee2b2c1..f722898db 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/bottom.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/bottom.md @@ -22,6 +22,11 @@ _**Output data type:** Object_ bottom(n:10, columns: ["_value"]) ``` +{{% warn %}} +#### Empty tables +`bottom()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/distinct.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/distinct.md index b1ea29c68..d9873cc35 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/distinct.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/distinct.md @@ -24,6 +24,11 @@ _**Output data type:** Object_ distinct(column: "host") ``` +{{% warn %}} +#### Empty tables +`distinct()` drops empty tables. +{{% /warn %}} + ## Parameters ### column diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first.md index 427d5a54a..7da75328c 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/first.md @@ -23,6 +23,11 @@ _**Output data type:** Object_ first() ``` +{{% warn %}} +#### Empty tables +`first()` drops empty tables. +{{% /warn %}} + ## Examples ```js from(bucket:"example-bucket") diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestaverage.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestaverage.md index 7cf9d502c..f8f0c2748 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestaverage.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestaverage.md @@ -24,6 +24,11 @@ highestAverage( ) ``` +{{% warn %}} +#### Empty tables +`highestAverage()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent.md index ca0a922b0..d9e35c4bd 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestcurrent.md @@ -24,6 +24,11 @@ highestCurrent( ) ``` +{{% warn %}} +#### Empty tables +`highestCurrent()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestmax.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestmax.md index e9268edcf..1e60beabd 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestmax.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/highestmax.md @@ -24,6 +24,11 @@ highestMax( ) ``` +{{% warn %}} +#### Empty tables +`highestMax()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last.md index 4f370060f..4d5490c1a 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last.md @@ -23,6 +23,11 @@ _**Output data type:** Object_ last() ``` +{{% warn %}} +#### Empty tables +`last()` drops empty tables. +{{% /warn %}} + ## Examples ```js from(bucket:"example-bucket") diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage.md index d1ea9fe7c..bea024aca 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestaverage.md @@ -24,6 +24,11 @@ lowestAverage( ) ``` +{{% warn %}} +#### Empty tables +`lowestAverage()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent.md index eab20a443..34d2db69b 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestcurrent.md @@ -24,6 +24,11 @@ lowestCurrent( ) ``` +{{% warn %}} +#### Empty tables +`lowestCurrent()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestmin.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestmin.md index 8a0cdc57a..1651afebc 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestmin.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/lowestmin.md @@ -24,6 +24,11 @@ lowestMin( ) ``` +{{% warn %}} +#### Empty tables +`lowestMin()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/max.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/max.md index 0c7956566..5fb669c00 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/max.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/max.md @@ -22,6 +22,11 @@ _**Output data type:** Object_ max(column: "_value") ``` +{{% warn %}} +#### Empty tables +`max()` drops empty tables. +{{% /warn %}} + ## Parameters ### column diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/min.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/min.md index 63a7bf673..8ff2002aa 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/min.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/min.md @@ -22,6 +22,11 @@ _**Output data type:** Object_ min(column: "_value") ``` +{{% warn %}} +#### Empty tables +`min()` drops empty tables. +{{% /warn %}} + ## Parameters ### column diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/sample.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/sample.md index acb8fd9d0..0c63938c6 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/sample.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/sample.md @@ -22,6 +22,11 @@ _**Output data type:** Object_ sample(n:5, pos: -1) ``` +{{% warn %}} +#### Empty tables +`sample()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/top.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/top.md index 630bf8f4e..03d24faf0 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/top.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/top.md @@ -20,6 +20,11 @@ _**Output data type:** Object_ top(n:10, columns: ["_value"]) ``` +{{% warn %}} +#### Empty tables +`top()` drops empty tables. +{{% /warn %}} + ## Parameters ### n diff --git a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique.md b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique.md index 899ca0bd2..6ff514cc7 100644 --- a/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique.md +++ b/content/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique.md @@ -21,6 +21,11 @@ _**Output data type:** Object_ unique(column: "_value") ``` +{{% warn %}} +#### Empty tables +`unique()` drops empty tables. +{{% /warn %}} + ## Parameters ### column 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) 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..28288d498 --- /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..f56bbc01b --- /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 + an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). +menu: + v2_0_ref: + name: teams.message + parent: Teams +weight: 202 +--- + +The `teams.message()` function sends a single message to a Microsoft Teams channel using +an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook). + +_**Function type:** Output_ + +```js +import "contrib/sranka/teams" + +teams.message( + url: "https://outlook.office.com/webhook/example-webhook", + title: "Example message title", + text: "Example message text", + summary: "", +) +``` + +## Parameters + +### url +Incoming webhook URL. + +_**Data type:** String_ + +### title +Message card title. + +_**Data type:** String_ + +### text +Message card text. + +_**Data type:** String_ + +### summary +Message card summary. +Default is `""`. +If no summary is provided, Flux generates the summary from the message text. + +_**Data type:** String_ + +## Examples + +##### Send the last reported status to a Microsoft Teams channel +```js +import "contrib/sranka/teams" + +lastReported = + from(bucket: "example-bucket") + |> range(start: -1m) + |> filter(fn: (r) => r._measurement == "statuses") + |> last() + |> findRecord(fn: (key) => true, idx: 0) + +teams.message( + url: "https://outlook.office.com/webhook/example-webhook", + title: "Disk Usage" + text: "Disk usage is: *${lastReported.status}*.", + summary: "Disk usage is ${lastReported.status}" +) +``` + +{{% note %}} +#### Package author and maintainer +**Github:** [@sranka](https://github.com/sranka) +**InfluxDB Slack:** [@sranka](https://influxdata.com/slack) +{{% /note %}} 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..c331817de --- /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 %}} diff --git a/content/v2.0/reference/flux/stdlib/date/hour.md b/content/v2.0/reference/flux/stdlib/date/hour.md index efdf143e7..1475e1a1d 100644 --- a/content/v2.0/reference/flux/stdlib/date/hour.md +++ b/content/v2.0/reference/flux/stdlib/date/hour.md @@ -29,5 +29,39 @@ date.hour(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the hour of a nanosecond Unix timestamp +```js +import "date" + +date.hour(t: 1581423663293534940) + +// Returns 12 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/microsecond.md b/content/v2.0/reference/flux/stdlib/date/microsecond.md index bd4cbba76..acadd5084 100644 --- a/content/v2.0/reference/flux/stdlib/date/microsecond.md +++ b/content/v2.0/reference/flux/stdlib/date/microsecond.md @@ -29,5 +29,39 @@ date.microsecond(t: 2019-07-17T12:05:21.012934584Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the microsecond of a nanosecond Unix timestamp +```js +import "date" + +date.microsecond(t: 1581423663293534940) + +// Returns 293534 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/millisecond.md b/content/v2.0/reference/flux/stdlib/date/millisecond.md index 6d7a6285e..0febcb59b 100644 --- a/content/v2.0/reference/flux/stdlib/date/millisecond.md +++ b/content/v2.0/reference/flux/stdlib/date/millisecond.md @@ -29,5 +29,39 @@ date.millisecond(t: 2019-07-17T12:05:21.012934584Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the millisecond of a nanosecond Unix timestamp +```js +import "date" + +date.millisecond(t: 1581423663293534940) + +// Returns 293 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/minute.md b/content/v2.0/reference/flux/stdlib/date/minute.md index 5e5ec0b34..2706460e6 100644 --- a/content/v2.0/reference/flux/stdlib/date/minute.md +++ b/content/v2.0/reference/flux/stdlib/date/minute.md @@ -29,5 +29,39 @@ date.minute(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the minute of a nanosecond Unix timestamp +```js +import "date" + +date.minute(t: 1581423663293534940) + +// Returns 21 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/month.md b/content/v2.0/reference/flux/stdlib/date/month.md index 6612dedd4..eaa2208fc 100644 --- a/content/v2.0/reference/flux/stdlib/date/month.md +++ b/content/v2.0/reference/flux/stdlib/date/month.md @@ -29,5 +29,39 @@ date.month(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the month of a nanosecond Unix timestamp +```js +import "date" + +date.month(t: 1581423663293534940) + +// Returns 2 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/monthday.md b/content/v2.0/reference/flux/stdlib/date/monthday.md index fabc7d31b..b1ac40d64 100644 --- a/content/v2.0/reference/flux/stdlib/date/monthday.md +++ b/content/v2.0/reference/flux/stdlib/date/monthday.md @@ -29,5 +29,39 @@ date.monthDay(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the day of the month for a nanosecond Unix timestamp +```js +import "date" + +date.monthDay(t: 1581423663293534940) + +// Returns 11 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/nanosecond.md b/content/v2.0/reference/flux/stdlib/date/nanosecond.md index 9d05b1f72..610ced7aa 100644 --- a/content/v2.0/reference/flux/stdlib/date/nanosecond.md +++ b/content/v2.0/reference/flux/stdlib/date/nanosecond.md @@ -29,5 +29,39 @@ date.nanosecond(t: 2019-07-17T12:05:21.012934584Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the nanosecond for a nanosecond Unix timestamp +```js +import "date" + +date.nanosecond(t: 1581423663293534940) + +// Returns 293534940Z +``` diff --git a/content/v2.0/reference/flux/stdlib/date/quarter.md b/content/v2.0/reference/flux/stdlib/date/quarter.md index a2f05b0f9..56edb7ed7 100644 --- a/content/v2.0/reference/flux/stdlib/date/quarter.md +++ b/content/v2.0/reference/flux/stdlib/date/quarter.md @@ -29,5 +29,39 @@ date.quarter(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the quarter for a nanosecond Unix timestamp +```js +import "date" + +date.quarter(t: 1581423663293534940) + +// Returns 1 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/second.md b/content/v2.0/reference/flux/stdlib/date/second.md index e7cc28f7f..302700305 100644 --- a/content/v2.0/reference/flux/stdlib/date/second.md +++ b/content/v2.0/reference/flux/stdlib/date/second.md @@ -29,5 +29,39 @@ date.second(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the second of a nanosecond Unix timestamp +```js +import "date" + +date.second(t: 1581423663293534940) + +// 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 762cfffcd..5f13e548b 100644 --- a/content/v2.0/reference/flux/stdlib/date/truncate.md +++ b/content/v2.0/reference/flux/stdlib/date/truncate.md @@ -30,8 +30,11 @@ date.truncate( ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ ### unit The unit of time to truncate to. @@ -44,16 +47,47 @@ For example: `1s`, `1m`, `1h`. {{% /note %}} ## Examples + +##### Truncate time values ```js import "date" -date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1s) -// Returns 2019-06-03T13:59:01.000000000Z +date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1s) +// Returns 2019-06-03T13:59:01.000000000Z -date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1m) -// Returns 2019-06-03T13:59:00.000000000Z - -date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1h) -// Returns 2019-06-03T13:00:00.000000000Z +date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1m) +// Returns 2019-06-03T13:59:00.000000000Z +date.truncate(t: 2019-06-03T13:59:01.000000000Z, unit: 1h) +// Returns 2019-06-03T13:00:00.000000000Z +``` + +##### Truncate time values using durations +```js +import "date" + +option now = () => 2020-01-01T00:00:30.500000000Z + +date.truncate(t: -30s, unit: 1s) +// Returns 2019-12-31T23:59:30.000000000Z + +date.truncate(t: -1m, unit: 1m) +// Returns 2019-12-31T23:59:00.000000000Z + +date.truncate(t: -1h, unit: 1h) +// Returns 2019-12-31T23:00:00.000000000Z +``` + +##### Truncate time values using nanosecond Unix timestamps +```js +import "date" + +date.truncate(t: 1559570341000000000, unit: 1s) +// Returns 2019-06-03T13:59:01.000000000Z + +date.truncate(t: 1559570341000000000, unit: 1m) +// Returns 2019-06-03T13:59:00.000000000Z + +date.truncate(t: 1559570341000000000, unit: 1h) +// Returns 2019-06-03T13:00:00.000000000Z ``` diff --git a/content/v2.0/reference/flux/stdlib/date/week.md b/content/v2.0/reference/flux/stdlib/date/week.md index dec8bddec..0eefcef9a 100644 --- a/content/v2.0/reference/flux/stdlib/date/week.md +++ b/content/v2.0/reference/flux/stdlib/date/week.md @@ -29,5 +29,39 @@ date.week(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the week of the year using a nanosecond Unix timestamp +```js +import "date" + +date.week(t: 1581423663293534940) + +// Returns 7 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/weekday.md b/content/v2.0/reference/flux/stdlib/date/weekday.md index 6e6fdb18c..437b01009 100644 --- a/content/v2.0/reference/flux/stdlib/date/weekday.md +++ b/content/v2.0/reference/flux/stdlib/date/weekday.md @@ -29,5 +29,39 @@ date.weekDay(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the day of the week for a nanosecond Unix timestamp +```js +import "date" + +date.weekDay(t: 1581423663293534940) + +// Returns 2 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/year.md b/content/v2.0/reference/flux/stdlib/date/year.md index f911a5976..3726c1cb8 100644 --- a/content/v2.0/reference/flux/stdlib/date/year.md +++ b/content/v2.0/reference/flux/stdlib/date/year.md @@ -27,5 +27,39 @@ date.year(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the year for a nanosecond Unix timestamp +```js +import "date" + +date.year(t: 1581423663293534940) + +// Returns 2020 +``` diff --git a/content/v2.0/reference/flux/stdlib/date/yearday.md b/content/v2.0/reference/flux/stdlib/date/yearday.md index 20df57afe..8e46b81cb 100644 --- a/content/v2.0/reference/flux/stdlib/date/yearday.md +++ b/content/v2.0/reference/flux/stdlib/date/yearday.md @@ -29,5 +29,39 @@ date.yearDay(t: 2019-07-17T12:05:21.012Z) ### t The time to operate on. +Use an absolute time, relative duration, or integer. +Durations are relative to `now()`. +Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp). -_**Data type:** Time_ +_**Data type:** Time | Duration | Integer_ + +## 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 +``` + +##### Return the day of the year for a nanosecond Unix timestamp +```js +import "date" + +date.yearDay(t: 1581423663293534940) + +// Returns 42 +``` diff --git a/content/v2.0/reference/flux/stdlib/http/pathescape.md b/content/v2.0/reference/flux/stdlib/http/pathescape.md new file mode 100644 index 000000000..1876c7d85 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/http/pathescape.md @@ -0,0 +1,45 @@ +--- +title: http.pathEscape() function +description: > + The `http.pathEscape()` function escapes special characters in a string (including `/`) + and replaces non-ASCII characters with hexadecimal representations (`%XX`). +menu: + v2_0_ref: + name: http.pathEscape + parent: HTTP +weight: 202 +--- + +The `http.pathEscape()` function escapes special characters in a string (including `/`) +and replaces non-ASCII characters with hexadecimal representations (`%XX`). + +_**Function type:** Transformation_ + +```js +import "http" + +http.pathEscape( + inputString: "/this/is/an/example-path.html" +) + +// Returns %2Fthis%2Fis%2Fan%2Fexample-path.html +``` + +## Parameters + +### inputString +The string to escape. + +_**Data type:** String_ + +## Examples + +##### URL-encode strings in a stream of tables +```js +import "http" + +data + |> map(fn: (r) => ({ r with + path: http.pathEscape(inputString: r.path) + })) +``` diff --git a/content/v2.0/reference/flux/stdlib/sql/_index.md b/content/v2.0/reference/flux/stdlib/sql/_index.md index 2fd8814e0..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, and SQLite. + as MySQL, PostgreSQL, Snowflake, SQLite, Microsoft SQL Server, and Amazon Athena. Import the `sql` package. aliases: - /v2.0/reference/flux/functions/sql/ @@ -17,8 +17,15 @@ related: - /v2.0/query-data/flux/sql/ --- -SQL Flux functions provide tools for working with data in SQL databases such as -MySQL, PostgreSQL, Snowflake, and SQLite. +SQL Flux functions provide tools for working with data in SQL databases such as: + +- Amazon Athena +- Microsoft SQL Server +- MySQL +- PostgreSQL +- Snowflake +- SQLite + Import the `sql` package: ```js diff --git a/content/v2.0/reference/flux/stdlib/sql/from.md b/content/v2.0/reference/flux/stdlib/sql/from.md index 0ecc56666..f48d16a92 100644 --- a/content/v2.0/reference/flux/stdlib/sql/from.md +++ b/content/v2.0/reference/flux/stdlib/sql/from.md @@ -35,10 +35,12 @@ _**Data type:** String_ The following drivers are available: +- awsathena - mysql - postgres - snowflake - sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#query-an-sqlite-database)._ +- sqlserver, mssql ### dataSourceName The data source name (DSN) or connection string used to connect to the SQL database. @@ -48,12 +50,16 @@ _**Data type:** String_ ##### Driver dataSourceName examples ```sh -# Postgres Driver DSN -postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full +# Amazon Athena Driver DSN +s3://myorgqueryresults/?accessID=AKIAJLO3F...®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F... +s3://myorgqueryresults/?accessID=AKIAJLO3F...&db=dbname&missingAsDefault=false&missingAsEmptyString=false®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...&WGRemoteCreation=false # MySQL Driver DSN username:password@tcp(localhost:3306)/dbname?param=value +# Postgres Driver DSN +postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full + # Snowflake Driver DSNs username[:password]@accountname/dbname/schemaname?param1=value1¶mN=valueN username[:password]@accountname/dbname?param1=value1¶mN=valueN @@ -61,6 +67,12 @@ username[:password]@hostname:port/dbname/schemaname?account=¶m # SQLite Driver DSN file:/path/to/test.db?cache=shared&mode=ro + +# Microsoft SQL Server Driver DSNs +sqlserver://username:password@localhost:1234?database=examplebdb +server=localhost;user id=username;database=examplebdb; +server=localhost;user id=username;database=examplebdb;azure auth=ENV +server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789 ``` ### query @@ -70,6 +82,13 @@ _**Data type:** String_ ## Examples +- [MySQL](#query-a-mysql-database) +- [Postgres](#query-a-postgres-database) +- [Snowflake](#query-a-snowflake-database) +- [SQLite](#query-an-sqlite-database) +- [Amazon Athena](#query-an-amazon-athena-database) +- [SQL Server](#query-a-sql-server-database) + {{% note %}} The examples below use [InfluxDB secrets](/v2.0/security/secrets/) to populate sensitive connection credentials. @@ -139,3 +158,95 @@ sql.from( query: "SELECT * FROM example_table" ) ``` + +### Query an Amazon Athena database +```js +import "sql" +import "influxdata/influxdb/secrets" + +region = us-west-1 +accessID = secrets.get(key: "ATHENA_ACCESS_ID") +secretKey = secrets.get(key: "ATHENA_SECRET_KEY") + +sql.from( + driverName: "awsathena", + dataSourceName: "s3://myorgqueryresults/?accessID=${accessID}®ion=${region}&secretAccessKey=${secretKey}", + query:"SELECT * FROM example_table" +) +``` + +##### Athena connection string +To query an Amazon Athena database, use the following query parameters in your Athena +S3 connection string (DSN): + +\* 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" +import "influxdata/influxdb/secrets" + +username = secrets.get(key: "SQLSERVER_USER") +password = secrets.get(key: "SQLSERVER_PASS") + +sql.from( + driverName: "sqlserver", + dataSourceName: "sqlserver://${username}:${password}@localhost:1234?database=examplebdb", + query: "GO SELECT * FROM Example.Table" +) +``` + +#### SQL Server ADO authentication +Use one of the following methods to provide SQL Server authentication credentials as +[ActiveX Data Objects (ADO)](https://docs.microsoft.com/en-us/sql/ado/guide/ado-introduction?view=sql-server-ver15) +connection string parameters: + +- [Retrieve authentication credentials from environment variables](#retrieve-authentication-credentials-from-environment-variables) +- [Retrieve authentication credentials from a file](#retrieve-authentication-credentials-from-a-file) +- [Specify authentication credentials in the connection string](#specify-authentication-credentials-in-the-connection-string) +- [Use a Managed identity in an Azure VM](#use-a-managed-identity-in-an-azure-vm) + +##### Retrieve authentication credentials from environment variables +``` +azure auth=ENV +``` + +##### Retrieve authentication credentials from a file +{{% warn %}} +**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ provide +access to the underlying file system and do not support reading credentials from a file. +To retrieve SQL Server credentials from a file, execute the query in the +[Flux REPL](/v2.0/reference/cli/influx/repl/) on your local machine. +{{% /warn %}} + +```powershel +azure auth=C:\secure\azure.auth +``` + +##### Specify authentication credentials in the connection string +```powershell +# Example of providing tenant ID, client ID, and client secret token +azure tenant id=77...;azure client id=58...;azure client secret=0cf123.. + +# Example of providing tenant ID, client ID, certificate path and certificate password +azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY... + +# Example of providing tenant ID, client ID, and Azure username and password +azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1... +``` + +##### Use a managed identity in an Azure VM +_For information about managed identities, see [Microsoft managed identities](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview)._ + +``` +azure auth=MSI +``` diff --git a/content/v2.0/reference/flux/stdlib/sql/to.md b/content/v2.0/reference/flux/stdlib/sql/to.md index 4d94200ef..0dc69b006 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 + +# Microsoft SQL Server Driver DSNs +sqlserver://username:password@localhost:1234?database=examplebdb +server=localhost;user id=username;database=examplebdb; +server=localhost;user id=username;database=examplebdb;azure auth=ENV +server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789 ``` ### table @@ -79,6 +86,12 @@ If writing to a **SQLite** database, set `batchSize` to `999` or less. ## Examples +- [MySQL](#write-data-to-a-mysql-database) +- [Postgres](#write-data-to-a-postgres-database) +- [Snowflake](#write-data-to-a-snowflake-database) +- [SQLite](#write-data-to-an-sqlite-database) +- [SQL Server](#write-data-to-a-sql-server-database) + {{% note %}} The examples below use [InfluxDB secrets](/v2.0/security/secrets/) to populate sensitive connection credentials. @@ -148,3 +161,69 @@ sql.to( table: "example_table" ) ``` + +### Write data to a SQL Server database +```js +import "sql" +import "influxdata/influxdb/secrets" + +username = secrets.get(key: "SQLSERVER_USER") +password = secrets.get(key: "SQLSERVER_PASS") + +sql.to( + driverName: "sqlserver", + dataSourceName: "sqlserver://${username}:${password}@localhost:1234?database=examplebdb", + table: "Example.Table" +) +``` + +#### SQL Server ADO authentication +Use one of the following methods to provide SQL Server authentication credentials as +[ActiveX Data Objects (ADO)](https://docs.microsoft.com/en-us/sql/ado/guide/ado-introduction?view=sql-server-ver15) +connection string parameters: + +- [Retrieve authentication credentials from environment variables](#retrieve-authentication-credentials-from-environment-variables) +- [Retrieve authentication credentials from a file](#retrieve-authentication-credentials-from-a-file) +- [Specify authentication credentials in the connection string](#specify-authentication-credentials-in-the-connection-string) +- [Use a Managed identity in an Azure VM](#use-a-managed-identity-in-an-azure-vm) + +##### Retrieve authentication credentials from environment variables +``` +azure auth=ENV +``` + +##### Retrieve authentication credentials from a file +{{% warn %}} +**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ provide +access to the underlying file system and do not support reading credentials from a file. +To retrieve SQL Server credentials from a file, execute the query in the +[Flux REPL](/v2.0/reference/cli/influx/repl/) on your local machine. +{{% /warn %}} + +```powershell +azure auth=C:\secure\azure.auth +``` + +##### Specify authentication credentials in the connection string +```powershell +# Example of providing tenant ID, client ID, and client secret token +azure tenant id=77...;azure client id=58...;azure client secret=0cf123.. + +# Example of providing tenant ID, client ID, certificate path and certificate password +azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY... + +# Example of providing tenant ID, client ID, and Azure username and password +azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1... +``` + +##### Use a managed identity in an Azure VM +_For information about managed identities, see [Microsoft managed identities](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview)._ + +``` +azure auth=MSI +``` + +{{% warn %}} +### sql.to does not support Amazon Athena +The `sql.to` function does not support writing data to [Amazon Athena](https://aws.amazon.com/athena/). +{{% /warn %}} diff --git a/content/v2.0/reference/key-concepts/data-elements.md b/content/v2.0/reference/key-concepts/data-elements.md index 89cb7484f..7fec5eaf8 100644 --- a/content/v2.0/reference/key-concepts/data-elements.md +++ b/content/v2.0/reference/key-concepts/data-elements.md @@ -31,12 +31,12 @@ _Hover over highlighted terms to get acquainted with InfluxDB terminology and la **bucket:** `my_bucket` -| _time | _measurement | location | scientist | _field | _value | -|:------------------- |:------------ |:------- |:------ |:-- |:------ | -| 2019-08-18T00:00:00Z | census | klamath | anderson | bees | 23 | -| 2019-08-18T00:00:00Z | census | portland | mullen | ants | 30 | -| 2019-08-18T00:06:00Z | census | klamath | anderson | bees | 28 | -| 2019-08-18T00:06:00Z | census | portland | mullen | ants | 32 | +| _time | _measurement | {{< tooltip "Tag key" "location" >}} | {{< tooltip "Tag key" "scientist" >}} | _field | _value | +|:------------------- |:------------ |:------- |:------ |:-- |:------ | +| 2019-08-18T00:00:00Z | census | klamath | anderson | bees | 23 | +| 2019-08-18T00:00:00Z | census | portland | mullen | ants | 30 | +| 2019-08-18T00:06:00Z | census | klamath | anderson | bees | 28 | +| {{< tooltip "Timestamp" "2019-08-18T00:06:00Z" >}} | {{< tooltip "measurement" "census" >}} | {{< tooltip "Tag value" "portland" >}} | {{< tooltip "Tag value" "mullen">}} | {{< tooltip "Field key" "ants" >}} | {{< tooltip "Field value" "32" >}} | ## Timestamp @@ -83,11 +83,13 @@ Tags include tag keys and tag values that are stored as strings and metadata. ### Tag key The tag keys in the sample data are `location` and `scientist`. +_For information about tag key requirements, see [Line protocol – Tag set](/v2.0/reference/syntax/line-protocol/#tag-set)._ ### Tag value The tag key `location` has two tag values: `klamath` and `portland`. The tag key `scientist` also has two tag values: `anderson` and `mullen`. +_For information about tag value requirements, see [Line protocol – Tag set](/v2.0/reference/syntax/line-protocol/#tag-set)._ ### Tag set @@ -117,19 +119,19 @@ from(bucket: "bucket-name") InfluxDB scans every field value in the dataset for `bees` before the query returns a response. If our sample `census` data grew to millions of rows, to optimize your query, you could rearrange your [schema](/v2.0/reference/glossary/#schema) so the fields (`bees` and `ants`) becomes tags and the tags (`location` and `scientist`) become fields: -| _time | _measurement | bees | _field | _value | -|:------------------- |:------------ |:------- |:-- |:------ | -| 2019-08-18T00:00:00Z | census | 23 | location | klamath | -| 2019-08-18T00:00:00Z | census | 23 | scientist | anderson | -| 2019-08-18T00:06:00Z | census | 28 | location | klamath | -| 2019-08-18T00:06:00Z | census | 28 | scientist | anderson | +| _time | _measurement | {{< tooltip "Tag key" "bees" >}} | _field | _value | +|:------------------- |:------------ |:------- |:-- |:------ | +| 2019-08-18T00:00:00Z | census | 23 | location | klamath | +| 2019-08-18T00:00:00Z | census | 23 | scientist | anderson | +| 2019-08-18T00:06:00Z | census | {{< tooltip "Tag value" "28" >}} | {{< tooltip "Field key" "location" >}} | {{< tooltip "Field value" "klamath" >}} | +| 2019-08-18T00:06:00Z | census | 28 | scientist | anderson | -| _time | _measurement | ants | _field | _value | -|:------------------- |:------------ |:------- |:-- |:------ | -| 2019-08-18T00:00:00Z | census | 30 | location | portland | -| 2019-08-18T00:00:00Z | census | 30 | scientist | mullen | -| 2019-08-18T00:06:00Z | census | 32 | location | portland| -| 2019-08-18T00:06:00Z | census | 32 | scientist | mullen | +| _time | _measurement | {{< tooltip "Tag key" "ants" >}} | _field | _value | +|:------------------- |:------------ |:------- |:-- |:------ | +| 2019-08-18T00:00:00Z | census | 30 | location | portland | +| 2019-08-18T00:00:00Z | census | 30 | scientist | mullen | +| 2019-08-18T00:06:00Z | census | {{< tooltip "Tag value" "32" >}} | {{< tooltip "Field key" "location" >}} | {{< tooltip "Field value" "portland" >}} | +| 2019-08-18T00:06:00Z | census | 32 | scientist | mullen | Now that `bees` and `ants` are tags, InfluxDB doesn't have to scan all `_field` and `_value` columns. This makes your queries faster. @@ -137,10 +139,10 @@ Now that `bees` and `ants` are tags, InfluxDB doesn't have to scan all `_field` Now that you're familiar with measurements, field sets, and tag sets, it's time to discuss series keys and series. A **series key** is a collection of points that share a measurement, tag set, and field key. For example, the [sample data](#sample-data) includes two unique series keys: -| _measurement | tag set | _field | -|:------------- |:------------------------------- |:------ | -| census | location=klamath,scientist=anderson |bees| -| census | location=portland,scientist=mullen | ants | +| _measurement | tag set | _field | +|:------------- |:------------------------------- |:------ | +| census | {{< tooltip "Tag set" "location=klamath,scientist=anderson" >}} | {{< tooltip "Field key" "bees" >}} | +| census | location=portland,scientist=mullen | ants | A **series** includes timestamps and field values for a given series key. From the sample data, here's a **series key** and the corresponding **series**: diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index 74c2a1bfa..63adf1dc8 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -11,11 +11,50 @@ aliases: --- {{% note %}} -_The latest release of InfluxDB v2.0 beta includes **Flux v0.71.1**. +The latest release of InfluxDB v2.0 beta includes **Flux v0.71.1**. Though newer versions of Flux may be available, they will not be included with InfluxDB until the next InfluxDB v2.0 release._ {{% /note %}} +## v0.71.1 [2020-07-03] + +### Bug fixes +- Add a check to ensure `every` is non-negative. + +--- + +## v0.71.0 [2020-06-30] + +### Features +- Apply `Timeable` constraint to integer type to support integer values in + time-related function parameters. +- Implement schema mutation functions without performing any copies. +- Add [`http.pathEscape()` function](/v2.0/reference/flux/stdlib/http/pathescape/). + +--- + +## v0.70.0 [2020-06-29] +### Features +- Update all `date` functions to accept time and duration types. +- Add [Microsoft Teams package](/v2.0/reference/flux/stdlib/contrib/teams/). +- Evaluate and store `now` in execution dependencies for `tableFind()`. +- Add `Timeable` constraint for time and duration types. +- Add [SQL Server support](/v2.0/reference/flux/stdlib/sql/from/#query-a-sql-server-database) to `sql` package. +- Add [Telegram package](/v2.0/reference/flux/stdlib/contrib/telegram/). +- Add [Amazon Athena support](/v2.0/reference/flux/stdlib/sql/from/#query-an-amazon-athena-database) to `sql` package. +- Add support for macOS builds. + +### Bug fixes +- Move semantic analysis to the finalize step. +- Fix check for stream equality. +- Fix the compiler's return type when `with` operator is used. +- Include `stdlib` Flux dependencies from the Flux `build.rs`. +- Include a hash of the sources for `libflux`. +- Flux test for [experimental `json.parse()`](/v2.0/reference/flux/stdlib/experimental/json/parse/). +- Reorder `go generate` call to `libflux` in `stdlib`. + +--- + ## v0.69.2 [2020-06-10] ### Bug fixes diff --git a/content/v2.0/reference/urls.md b/content/v2.0/reference/urls.md index 738cd6b58..f2bfd4d4d 100644 --- a/content/v2.0/reference/urls.md +++ b/content/v2.0/reference/urls.md @@ -12,15 +12,6 @@ menu: InfluxDB 2.0 is available both locally (OSS) or on multiple cloud providers in multiple regions (Cloud). -## InfluxDB OSS URL - -For InfluxDB OSS, the default URL is the following: - -{{< keep-url >}} -``` -http://localhost:9999/ -``` - ## InfluxDB Cloud URLs Each region has a unique InfluxDB Cloud URL and API endpoint. @@ -29,3 +20,35 @@ Use the URLs below to interact with your InfluxDB Cloud instances with the [`influx` CLI](/v2.0/reference/cli/influx/), or [Telegraf](/v2.0/write-data/use-telegraf/). {{< cloud_regions >}} + +## InfluxDB OSS URLs + +For InfluxDB OSS, the default URL is the following: + +{{< keep-url >}} +``` +http://localhost:9999/ +``` + +### Customize your InfluxDB OSS URL +To customize your InfluxDB host and port, use the +[`http-bind-address` configuration option](/v2.0/reference/config-options/#http-bind-address) +when starting `influxd`. + +```sh +# Syntax +influxd --http-bind-address : + +# Example - Run InfluxDB at http://example.com:8080 +influxd --http-bind-address example.com:8080 + +# Example - Run InfluxDB at http://localhost:8080 +influxd --http-bind-address :8080 +``` + +{{% note %}} +#### Configure DNS routing +You must configure DNS routing to successfully route requests to your custom hostname. +Methods for configuring DNS routing vary depending on your operating system and +network architecture and are not covered in this documentation. +{{% /note %}} diff --git a/content/v2.0/security/secrets/use-vault.md b/content/v2.0/security/secrets/use-vault.md index 7642a6751..2e69ef8b8 100644 --- a/content/v2.0/security/secrets/use-vault.md +++ b/content/v2.0/security/secrets/use-vault.md @@ -6,19 +6,23 @@ menu: v2_0: parent: Store and use secrets weight: 201 -products: [oss] --- -[Vault](https://www.vaultproject.io/) secures, stores, and tightly controls access +[Vault](https://www.vaultproject.io/) secures, stores, and controls access to tokens, passwords, certificates, and other sensitive secrets. -Store sensitive secrets in Vault using the InfluxDB built-in Vault integration. +Store sensitive secrets in Vault using InfluxDB's built-in Vault integration. + +## Use Vault with {{< cloud-name >}} -{{% cloud %}} By default, all secrets added to **InfluxDB Cloud** are stored in the **InfluxDB Cloud Vault cluster**. -{{% /cloud %}} -## Start a Vault server +For more on adding and using secrets, see [Manage secrets](/v2.0/security/secrets/manage-secrets/). +Once added, use the [`secrets.get()`](/v2.0/reference/flux/stdlib/secrets/get/) function to retrieve secrets for use in Flux scripts. + +## Use Vault with InfluxDB OSS + +### Start a Vault server Start a Vault server and ensure InfluxDB has network access to the server. @@ -43,26 +47,26 @@ For this example, install Vault on your local machine and start a Vault dev serv vault server -dev ``` -## Provide Vault server address and token +### Provide Vault server address and token Use `influxd` Vault-related tags or [Vault environment variables](https://www.vaultproject.io/docs/commands/index.html#environment-variables) to provide connection credentials and other important Vault-related information to InfluxDB. -### Required credentials +#### Required credentials -#### Vault address +##### Vault address Provide the API address of your Vault server _(available in the Vault server output)_ using the [`--vault-addr` flag](/v2.0/reference/config-options/#vault-addr) when starting `influxd` or with the `VAULT_ADDR` environment variable. -#### Vault token +##### Vault token Provide your [Vault token](https://learn.hashicorp.com/vault/getting-started/authentication) (required to access your Vault server) using the [`--vault-token` flag](/v2.0/reference/config-options/#vault-token) when starting `influxd` or with the `VAULT_TOKEN` environment variable. _Your Vault server configuration may require other Vault settings._ -## Start InfluxDB +### Start InfluxDB Start the [`influxd` service](/v2.0/reference/cli/influxd/) with the `--secret-store` option set to `vault` any other necessary flags. @@ -89,6 +93,6 @@ If set, these flags override any [Vault environment variables](https://www.vault For more information, see [InfluxDB configuration options](/v2.0/reference/config-options/). -## Manage secrets through the InfluxDB API +### Manage secrets through the InfluxDB API Use the InfluxDB `/org/{orgID}/secrets` API endpoint to add tokens to Vault. For details, see [Manage secrets](/v2.0/security/secrets/manage-secrets/). diff --git a/content/v2.0/security/tokens/create-token.md b/content/v2.0/security/tokens/create-token.md index f5c1b93b2..882b70f52 100644 --- a/content/v2.0/security/tokens/create-token.md +++ b/content/v2.0/security/tokens/create-token.md @@ -14,6 +14,11 @@ weight: 201 Create authentication tokens using the InfluxDB user interface (UI) or the `influx` command line interface (CLI). + +Tokens are visible only to the user who created them and stop working when the user is deactivated. We recommend creating a generic IT user to create and manage tokens for writing data. + +## + ## Create a token in the InfluxDB UI 1. In the navigation menu on the left, select **Data (Load Data)** > **Tokens**. diff --git a/content/v2.0/security/tokens/view-tokens.md b/content/v2.0/security/tokens/view-tokens.md index 7e2730e50..c583e4e70 100644 --- a/content/v2.0/security/tokens/view-tokens.md +++ b/content/v2.0/security/tokens/view-tokens.md @@ -14,6 +14,10 @@ weight: 202 View authentication tokens using the InfluxDB user interface (UI) or the `influx` command line interface (CLI). +{{% note %}} +Tokens are visible only to the user who created them and stop working when the user is deactivated. We recommend creating a generic IT user to create and manage tokens for writing data. +{{% note %}} + ## View tokens in the InfluxDB UI 1. In the navigation menu on the left, select **Data (Load Data)** > **Tokens**. diff --git a/content/v2.0/visualize-data/dashboards/export-dashboard.md b/content/v2.0/visualize-data/dashboards/export-dashboard.md index 4a0f8496a..31631991d 100644 --- a/content/v2.0/visualize-data/dashboards/export-dashboard.md +++ b/content/v2.0/visualize-data/dashboards/export-dashboard.md @@ -13,11 +13,9 @@ weight: 203 InfluxDB lets you export dashboards from the InfluxDB user interface (UI). -## Export a dashboard - 1. In the navigation menu on the left, select **Boards** (**Dashboards**). - {{< nav-icon "dashboards" >}} + {{< nav-icon "dashboards" >}} 2. Hover over a dashboard and click the gear icon (**{{< icon "gear" >}}**), and then select **Export**. diff --git a/content/v2.0/write-data/_index.md b/content/v2.0/write-data/_index.md index f15aa7720..3978acb48 100644 --- a/content/v2.0/write-data/_index.md +++ b/content/v2.0/write-data/_index.md @@ -149,7 +149,7 @@ After [setting up InfluxDB v2.0](/v2.0/get-started/#set-up-influxdb), the "Let's start collecting data!" page displays options for collecting data. Click **Quick Start**. -InfluxDB creates and configures a new [scraper](/v2.0/write-data/scrape-data/). +InfluxDB creates and configures a new [scraper](/v2.0/write-data/no-code/scrape-data/). The target URL points to the `/metrics` HTTP endpoint of your local InfluxDB instance (for example, `http://localhost:9999/metrics`), which outputs internal InfluxDB metrics in the [Prometheus data format](https://prometheus.io/docs/instrumenting/exposition_formats/). diff --git a/content/v2.0/write-data/best-practices/optimize-writes.md b/content/v2.0/write-data/best-practices/optimize-writes.md index d5456f161..0d10a30e5 100644 --- a/content/v2.0/write-data/best-practices/optimize-writes.md +++ b/content/v2.0/write-data/best-practices/optimize-writes.md @@ -11,16 +11,21 @@ v2.0/tags: [best practices, write] Use these tips to optimize performance and system overhead when writing data to InfluxDB. +- [Batch writes](#batch-writes) +- [Sort tags by key](#sort-tags-by-key) +- [Use the coarsest time precision possible](#use-the-coarsest-time-precision-possible) +- [Use gzip compression](#use-gzip-compression) +- [Synchronize hosts with NTP](#synchronize-hosts-with-ntp) +- [Write multiple data points in one request](#write-multiple-data-points-in-one-request) + {{% note %}} -The following tools write to InfluxDB and employ write optimizations by default: +The following tools write to InfluxDB and employ _most_ write optimizations by default: - [Telegraf](/v2.0/write-data/use-telegraf/) -- [InfluxDB scrapers](/v2.0/write-data/scrape-data/) - [InfluxDB client libraries](/v2.0/reference/api/client-libraries/) +- [InfluxDB scrapers](/v2.0/write-data/no-code/scrape-data/) {{% /note %}} ---- - ## Batch writes Write data in batches to minimize network overhead when writing data to InfluxDB. @@ -50,6 +55,53 @@ For better performance, use the coarsest precision possible for timestamps. _Specify timestamp precision when [writing to InfluxDB](/v2.0/write-data/#timestamp-precision)._ +## Use gzip compression + +Use gzip compression to speed up writes to InfluxDB. +Benchmarks have shown up to a 5x speed improvement when data is compressed. + +{{< tabs-wrapper >}} +{{% tabs %}} +[Telegraf](#) +[Client libraries](#) +[InfluxDB API](#) +{{% /tabs %}} +{{% tab-content %}} +### Enable gzip compression in Telegraf + +In the `influxdb_v2` output plugin configuration in your `telegraf.conf`, set the +`content_encoding` option to `gzip`: + +```toml +[[outputs.influxdb_v2]] + urls = ["http://localhost:9999"] + # ... + content_encoding = "gzip" +``` +{{% /tab-content %}} +{{% tab-content %}} +### Enable gzip compression in InfluxDB client libraries + +Each [InfluxDB client library](/v2.0/reference/api/client-libraries/) provides +options for compressing write requests or enforces compression by default. +The method for enabling compression is different for each library. +For specific instructions, see the [InfluxDB client libraries documentation](/v2.0/reference/api/client-libraries/). +{{% /tab-content %}} +{{% tab-content %}} +### Use gzip compression with the InfluxDB API + +When using the InfluxDB API `/write` endpoint to write data, set the `Content-Encoding` +header to `gzip` to compress the request data. + +```sh +curl -XPOST "http://localhost:9999/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \ + --header "Authorization: Token YOURAUTHTOKEN" \ + --header "Content-Encoding: gzip" \ + --data-raw "mem,host=host1 used_percent=23.43234543 1556896326" +``` +{{% /tab-content %}} +{{< /tabs-wrapper >}} + ## Synchronize hosts with NTP Use the Network Time Protocol (NTP) to synchronize time between hosts. diff --git a/content/v2.0/write-data/no-code/scrape-data/_index.md b/content/v2.0/write-data/no-code/scrape-data/_index.md index 46ba45d04..f55664707 100644 --- a/content/v2.0/write-data/no-code/scrape-data/_index.md +++ b/content/v2.0/write-data/no-code/scrape-data/_index.md @@ -8,6 +8,7 @@ description: > aliases: - /v2.0/collect-data/scraper-metrics-endpoint - /v2.0/collect-data/scrape-data + - /v2.0/write-data/scrape-data - /v2.0/write-data/scrapable-endpoints v2.0/tags: [scraper] menu: diff --git a/content/v2.0/write-data/no-code/scrape-data/manage-scrapers/update-a-scraper.md b/content/v2.0/write-data/no-code/scrape-data/manage-scrapers/update-a-scraper.md index e55f92a93..39c4177a2 100644 --- a/content/v2.0/write-data/no-code/scrape-data/manage-scrapers/update-a-scraper.md +++ b/content/v2.0/write-data/no-code/scrape-data/manage-scrapers/update-a-scraper.md @@ -16,7 +16,7 @@ Update a scraper in the InfluxDB user interface (UI). {{% note %}} Scraper **Target URLs** and **Buckets** cannot be updated. -To modify either, [create a new scraper](/v2.0/write-data/scrape-data/manage-scrapers/create-a-scraper). +To modify either, [create a new scraper](/v2.0/write-data/no-code/scrape-data/manage-scrapers/create-a-scraper). {{% /note %}} ## Update a scraper in the InfluxDB UI diff --git a/data/influxdb_urls.yml b/data/influxdb_urls.yml index 202b9fd73..bb1b48fd2 100644 --- a/data/influxdb_urls.yml +++ b/data/influxdb_urls.yml @@ -5,6 +5,8 @@ oss: regions: - name: localhost:9999 url: http://localhost:9999 + - name: Custom + url: http://example.com:8080 cloud: product: InfluxDB Cloud diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 27e88acbf..b65d43017 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -21,5 +21,5 @@ - {{ partial "footer/javascript.html" }} + {{ partial "footer/javascript.html" . }} diff --git a/layouts/partials/footer/influxdb-url-modal.html b/layouts/partials/footer/influxdb-url-modal.html index 97028500b..9b14f0ce5 100644 --- a/layouts/partials/footer/influxdb-url-modal.html +++ b/layouts/partials/footer/influxdb-url-modal.html @@ -14,16 +14,31 @@
{{ range .providers }}
-
{{ if .short_name}}{{ .short_name }}{{ else }}{{ .name }}{{ end }}
-
    - {{ range .regions }} -
  • - -
  • + {{ if eq .name "Custom" }} +
    Custom
    +
      +
    • + +
      + +
      +
    • +
    + {{ else }} +
    {{ if .short_name}}{{ .short_name }}{{ else }}{{ .name }}{{ end }}
    +
      + {{ range .regions }} +
    • + +
    • + {{ end }} {{ end }}
diff --git a/layouts/partials/footer/javascript.html b/layouts/partials/footer/javascript.html index 44e53db65..56ad03440 100644 --- a/layouts/partials/footer/javascript.html +++ b/layouts/partials/footer/javascript.html @@ -3,6 +3,16 @@ {{ $searchInteractions := resources.Get "js/search-interactions.js" }} {{ $telegrafFilters := resources.Get "js/telegraf-filters.js" }} {{ $influxdbURLs := resources.Get "js/influxdb-url.js" }} -{{ $footerjs := slice $versionSelector $contentInteractions $searchInteractions $telegrafFilters $influxdbURLs | resources.Concat "js/footer.bundle.js" | resources.Fingerprint}} +{{ $footerjs := slice $versionSelector $contentInteractions $searchInteractions $telegrafFilters $influxdbURLs | resources.Concat "js/footer.bundle.js" | resources.Fingerprint }} + + + + diff --git a/layouts/shortcodes/tooltip.html b/layouts/shortcodes/tooltip.html new file mode 100644 index 000000000..29dcae824 --- /dev/null +++ b/layouts/shortcodes/tooltip.html @@ -0,0 +1,3 @@ +{{ $tooltip := .Get 0 }} +{{ $text := .Get 1 }} +{{ $text }}