Update examples to use noaa bucket recommended in sample data page

pull/1657/head
noramullen1 2020-10-21 12:55:51 -07:00
parent 5556e3f8cd
commit b412281237
7 changed files with 31 additions and 7 deletions

View File

@ -10,6 +10,10 @@ weight: 202
influxdb/v2.0/tags: [tasks]
---
{{% note %}}
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 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`).
@ -24,7 +28,7 @@ option task = {
every: 1w,
}
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
csv.from(bucket: "noaa")
|> filter(fn: (r) => r._measurement == "average_temperature")
|> range(start: 2019-09-01T11:24:00Z)
|> aggregateWindow(every: 1w, fn: mean)

View File

@ -11,11 +11,13 @@ menu:
weight: 203
influxdb/v2.0/tags: [tasks]
---
{{% note %}}
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
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:
- Uses [NOAA water database data](https://influx-testdata.s3.amazonaws.com/noaa.csv)
- 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.
@ -27,7 +29,7 @@ import "http"
import "json"
import "experimental/csv"
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
csv.from(bucket: "noaa")
|> filter(fn: (r) => r._measurement == "average_temperature")
|> mean()
|> map(fn: (r) => ({ r with

View File

@ -10,6 +10,10 @@ menu:
weight: 104
---
{{% note %}}
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
Use the [`map()` function](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to create a new column calculated from existing values in each row.
This example converts temperature from Fahrenheit to Celsius and maps the Celsius value to a new `celsius` column.

View File

@ -11,10 +11,14 @@ menu:
weight: 104
---
{{% note %}}
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).
The following query:
- Gets the last value in the `means` bucket and compares it to the last value in the `noaa` bucket using [`last()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last/)
- Gets the last value in the `means` bucket and compares it to the last value in the `noaa` bucket using [`last()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last/).
- Uses [`join()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/join/) to combine the results
- Uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/map/) to calculate the differences

View File

@ -10,7 +10,11 @@ menu:
weight: 104
---
The following examples use the sample NOAA weather data to identify and count unique locations that data was collected from.
{{% note %}}
This example uses [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
@ -19,7 +23,7 @@ This example uses [`csv.from()`](influxdb/v2.0/reference/flux/stdlib/csv/from/),
```js
import "experimental/csv"
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
csv.from(bucket: "noaa")
|> keep(columns: ["location"])
|> unique(column: "location")
```

View File

@ -9,6 +9,10 @@ menu:
weight: 104
---
{{% note %}}
This example uses [NOAA water sample data](/influxdb/v2.0/reference/sample-data/#noaa-water-sample-data).
{{% /note %}}
Use [`map()` function](/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 the `map` function 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.
@ -16,7 +20,7 @@ The following example uses [`map()`](/influxdb/v2.0/reference/flux/stdlib/built-
```js
import "experimental/csv"
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
csv.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

@ -69,3 +69,5 @@ import "experimental/csv"
csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv")
|> to(bucket: "noaa", org: "your-org")
```
_Used in [Common queries](/influxdb/v2.0/query-data/common-queries/) and [Common tasks](/influxdb/v2.0/process-data/common-tasks/)._