Address PR feedback, remove experimental mentions, standardize intros

pull/1657/head
noramullen1 2020-10-21 14:02:14 -07:00
parent 9de464ecc3
commit 851d385473
8 changed files with 35 additions and 39 deletions

View File

@ -15,8 +15,3 @@ weight: 104
The following articles walk through common task use cases.
{{< children >}}
{{% note %}}
This list will continue to grow.
If you have suggestions, please [submit them to the InfluxData Community](https://community.influxdata.com/c/influxdb2).
{{% /note %}}

View File

@ -14,21 +14,21 @@ influxdb/v2.0/tags: [tasks]
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
Calculate a weekly mean and store it in a separate bucket.
This example calculates a temperature weekly mean and stores it in a separate bucket.
This example groups average temperature by week and computes the mean using the [`aggregateWindow()` function](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/), then sends the weekly mean to a new bucket (`weekly_means`).
This example uses [NOAA water database data](https://influx-testdata.s3.amazonaws.com/noaa.csv) and the experimental [`csv.from()` function](/influxdb/v2.0/reference/flux/stdlib/experimental/csv/from/) to retrieve data used to calculate the weekly mean.
The following query:
- Uses [`filter()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/) to filter the `average_temperature` measurement.
- Uses [`range()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/range/) to define a time range.
- Uses [`aggregateWindow()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/) to group average temperature by week and compute the mean.
- Sends the weekly mean to a new bucket (`weekly_means`)
```js
import "experimental/csv"
option task = {
name: "weekly-means",
every: 1w,
}
csv.from(bucket: "noaa")
from(bucket: "noaa")
|> filter(fn: (r) => r._measurement == "average_temperature")
|> range(start: 2019-09-01T11:24:00Z)
|> aggregateWindow(every: 1w, fn: mean)

View File

@ -18,18 +18,17 @@ This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/
Send each record to a URL endpoint using the HTTP POST method. This example uses [`json.encode()`](/influxdb/v2.0/reference/flux/stdlib/json/encode/) to convert a value into JSON bytes, then uses [`http.post()`](/influxdb/v2.0/reference/flux/stdlib/http/post/) to send them to a URL endpoint.
The following query:
- Queries data from a data source ([`csv.from()`](/influxdb/v2.0/reference/flux/stdlib/experimental/csv/from/) and [`filter()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/))
- Calculates the average value from results using [`mean()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mean/)
- Uses map to create a new column, `jsonStr`, and build a JSON object using column values from the query. It then byte-encodes the JSON object and stores it as a string in the `jsonStr` column.
- Uses `http.post()` to send the `jsonStr` value from each record to an HTTP endpoint
- Uses [`filter()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/) to filter the `average_temperature` measurement.
- Uses [`mean()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mean/) to calculate the average value from results.
- Uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to create a new column, `jsonStr`, and build a JSON object using column values from the query. It then byte-encodes the JSON object and stores it as a string in the `jsonStr` column.
- Uses [`http.post()`](/influxdb/v2.0/reference/flux/stdlib/http/post/) to send the `jsonStr` value from each record to an HTTP endpoint.
```js
import "http"
import "json"
import "experimental/csv"
csv.from(bucket: "noaa")
from(bucket: "noaa")
|> filter(fn: (r) => r._measurement == "average_temperature")
|> mean()
|> map(fn: (r) => ({ r with

View File

@ -17,12 +17,11 @@ This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/
This example converts temperature from Fahrenheit to Celsius and maps the Celsius value to a new `celsius` column.
The following query:
- Uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to create a new column calculated from existing values in each row.
- Uses [`filter()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/) to filter the `average_temperature` measurement.
- Uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to create a new column calculated from existing values in each row.
```js
import "experimental/csv"
csv.from(bucket: "noaa")
from(bucket: "noaa")
|> filter(fn: (r) => r._measurement == "average_temperature")
|> map(fn: (r) => ({r with
celsius: ((r._value - 32.0) * 5.0 / 9.0)

View File

@ -15,7 +15,7 @@ weight: 104
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
Compare the value from the latest point to an average value stored in another bucket. This is useful when using the average value to calculate a [threshold check](/influxdb/v2.0/monitor-alert/checks/create/#threshold-check).
This example compares the value from the latest point to an average value stored in another bucket. This is useful when using the average value to calculate a [threshold check](/influxdb/v2.0/monitor-alert/checks/create/#threshold-check).
The following query:
- Uses [`range()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/range/) to define a time range.

View File

@ -11,37 +11,40 @@ weight: 104
---
{{% note %}}
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
These examples use [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
The following examples identify and count unique locations that data was collected from.
## Find unique values
This example uses [`csv.from()`](influxdb/v2.0/reference/flux/stdlib/csv/from/), [`keep()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keep/), and [`unique()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique/) to return unique values in a specified column.
This query:
- Uses [`group()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/group/) to ungroup data and return results in a single table.
- Uses [`keep()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keep/) and [`unique()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique/) to return unique values in the specified column.
```js
import "experimental/csv"
csv.from(bucket: "noaa")
|> group()
|> keep(columns: ["location"])
|> unique(column: "location")
```
### Example results
|result |table|location |
| -----:| ---:| ------: |
| |0 |coyote_creek|
| |1 |santa_monica|
| location |
|:-------- |
| coyote_creek |
| santa_monica |
## Count unique values
This example uses [`csv.from()`](influxdb/v2.0/reference/flux/stdlib/csv/from/), [`keep()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keep/), [`unique()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique/), and then [`count()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count/) to count the number of unique values. It first uses `group()` to ungroup data and return results in a single table.
This query:
- Uses [`group()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/group/) to ungroup data and return results in a single table.
- Uses [`keep()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/keep/), [`unique()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/unique/), and then [`count()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count/) to count the number of unique values.
```js
import "experimental/csv"
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
from(bucket: "noaa")
|> group()
|> unique(column: "location")
|> count(column: "location")

View File

@ -13,14 +13,15 @@ weight: 104
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
Use [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to recalculate the `_value` column without creating a new one. Use the `with` operator in [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to overwrite the existing `_value` column.
Recalculate the `_value` column without creating a new one. Use the `with` operator in [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to overwrite the existing `_value` column.
The following example uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to convert Fahrenheit temperature values into Celsius.
The following query:
- Uses [`filter()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/filter/) to filter the `average_temperature` measurement.
- Uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to convert Fahrenheit temperature values into Celsius.
```js
import "experimental/csv"
csv.from(bucket: "noaa")
from(bucket: "noaa")
|> filter(fn: (r) => r._measurement == "average_temperature")
|> map(fn: (r) => ({r with _value: (float(v: r._value) - 32.0) * 5.0 / 9.0} ))
```

View File

@ -54,14 +54,13 @@ to query and analyze the geo-temporal data in this sample data set.
_Used in [Work with geo-temporal data](/influxdb/v2.0/query-data/flux/geo/)._
### NOAA water sample data
This data set is publicly available data from the [National Oceanic and Atmospheric Administrations (NOAA) Center for Operational Oceanographic Products and Services](http://tidesandcurrents.noaa.gov/stations.html).
[The CSV data](https://influx-testdata.s3.amazonaws.com/noaa.csv) includes 15,258 observations of water levels (ft) collected every six minutes at two stations (Santa Monica, CA (ID 9410840) and Coyote Creek, CA (ID 9414575)) over the period from August 18, 2015 through September 18, 2015.
To avoid having to re-download this 10MB dataset every time you run a query, we recommend that you create a new bucket (`noaa`) and write the NOAA data to it. To do so, run the following:
To avoid having to re-download this 10MB dataset every time you run a query, we recommend that you [create a new bucket](/influxdb/v2.0/organizations/buckets/create-bucket/) (`noaa`) and write the NOAA data to it. To do so, run the following:
```js
import "experimental/csv"