Merge pull request #521 from influxdata/query-revision

Various edits to "Query Data" get-started pages
pull/523/head
pierwill 2019-10-14 12:50:37 -07:00 committed by GitHub
commit 08c9dc63d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 14 deletions

View File

@ -17,8 +17,8 @@ related:
Flux is InfluxData's functional data scripting language designed for querying,
analyzing, and acting on data.
This multi-part getting started guide walks through important concepts related to Flux,
how to query time series data from InfluxDB using Flux, and introduces Flux syntax and functions.
This multi-part getting started guide walks through important concepts related to Flux.
It covers querying time series data from InfluxDB using Flux, and introduces Flux syntax and functions.
## Flux design principles
Flux is designed to be usable, readable, flexible, composable, testable, contributable, and shareable.
@ -26,7 +26,7 @@ Its syntax is largely inspired by [2018's most popular scripting language](https
Javascript, and takes a functional approach to data exploration and processing.
The following example illustrates querying data stored from the last five minutes,
filtering by the `cpu` measurement and the `cpu=cpu-usage` tag, windowing the data in 1 minute intervals,
filtering by the `cpu` measurement and the `cpu=cpu-total` tag, windowing the data in 1 minute intervals,
and calculating the average of each window:
```js
@ -47,6 +47,7 @@ Flux uses pipe-forward operators (`|>`) extensively to chain operations together
After each function or operation, Flux returns a table or collection of tables containing data.
The pipe-forward operator pipes those tables into the next function or operation where
they are further processed or manipulated.
This makes it easy to chain together functions to build sophisticated queries.
### Tables
Flux structures all data in tables.

View File

@ -38,7 +38,7 @@ Flux will not query the database without a specified range.
Use the pipe-forward operator (`|>`) to pipe data from your data source into the [`range()`](/v2.0/reference/flux/stdlib/built-in/transformations/range)
function, which specifies a time range for your query.
It accepts two properties: `start` and `stop`.
It accepts two parameters: `start` and `stop`.
Ranges can be **relative** using negative [durations](/v2.0/reference/flux/language/lexical-elements#duration-literals)
or **absolute** using [timestamps](/v2.0/reference/flux/language/lexical-elements#date-and-time-literals).
@ -106,7 +106,7 @@ from(bucket:"example-bucket")
```
## 4. Yield your queried data
Use Flux's `yield()` function to output the filtered tables as the result of the query.
Flux's `yield()` function outputs the filtered tables as the result of the query.
```js
from(bucket:"example-bucket")
@ -119,16 +119,17 @@ from(bucket:"example-bucket")
|> yield()
```
{{% note %}}
Flux automatically assume a `yield()` function at
Flux automatically assumes a `yield()` function at
the end of each script in order to output and visualize the data.
`yield()` is only necessary when including multiple queries in the same Flux query.
Explicitly calling `yield()` is only necessary when including multiple queries in the same Flux query.
Each set of returned data needs to be named using the `yield()` function.
{{% /note %}}
## Congratulations!
You have now queried data from InfluxDB using Flux.
This is a barebones query that can be transformed in other ways.
The query shown here is a barebones example.
Flux queries can be extended in many ways to form powerful scripts.
<div class="page-nav-btns">
<a class="btn prev" href="/v2.0/query-data/get-started/">Get started with Flux</a>

View File

@ -186,10 +186,8 @@ topN = (tables=<-, n) => tables |> sort(desc: true) |> limit(n: n)
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}
_More information about creating custom functions is available in the [Custom functions](/v2.0/query-data/guides/custom-functions) documentation._
Using the `cpuUsageUser` data stream variable defined above, find the top five data
points with the custom `topN` function and yield the results.
Using this new custom function `topN` and the `cpuUsageUser` data stream variable defined above,
we can find the top five data points and yield the results.
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
@ -215,6 +213,8 @@ cpuUsageUser |> topN(n:5) |> yield()
This query will return the five data points with the highest user CPU usage over the last hour.
_More information about creating custom functions is available in the [Custom functions](/v2.0/query-data/guides/custom-functions) documentation._
<div class="page-nav-btns">
<a class="btn prev" href="/v2.0/query-data/get-started/transform-data/">Transform your data</a>
</div>

View File

@ -19,6 +19,7 @@ Common examples are aggregating data into averages, downsampling data, etc.
This guide demonstrates using [Flux functions](/v2.0/reference/flux/stdlib) to transform your data.
It walks through creating a Flux script that partitions data into windows of time,
averages the `_value`s in each window, and outputs the averages as a new table.
(Remember, Flux structures all data in [tables](/v2.0/query-data/get-started/#tables).)
It's important to understand how the "shape" of your data changes through each of these operations.