restructured query data section

pull/22/head
Scott Anderson 2019-01-22 09:46:01 -07:00
parent 6024e26dcc
commit 2c0f6eeca3
16 changed files with 75 additions and 112 deletions

View File

@ -7,6 +7,7 @@ menu:
weight: 1
#enterprise_all: true
enterprise_some: true
draft: true
---
This is a paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum, metus id scelerisque euismod, erat ante suscipit nibh, ac congue enim risus id est. Etiam tristique nisi et tristique auctor. Morbi eu bibendum erat. Sed ullamcorper, dui id lobortis efficitur, mauris odio pharetra neque, vel tempor odio dolor blandit justo.

View File

@ -8,4 +8,16 @@ menu:
weight: 2
---
_Placeholder content for the query data page._
Flux is InfluxData's functional data scripting language designed for querying, analyzing, and acting on data.
## Get started with Flux
The best way to familiarize yourself with Flux is to walk through creating a simple Flux query.
[Get Started with Flux](/v2.0/query-data/get-started)
## Execute queries
A guide that covers the different options for executing Flux queries with InfluxDB.
[Different ways to execute Flux queries](/v2.0/query-data/execute-queries)
## How-to guides

View File

@ -1,15 +1,15 @@
---
title: Execute Flux queries
seotitle: Different ways to execute Flux queries
description: There are multiple ways to execute Flux queries include the InfluxDB user interface, CLI, and API.
title: Execute queries
seotitle: Different ways to query InfluxDB
description: There are multiple ways to query data from InfluxDB including the the InfluxDB UI, CLI, and API.
menu:
v2_0:
name: Execute Flux queries
parent: How-to guides
weight: 1
name: Execute queries
parent: Query data
weight: 2
---
There are multiple ways to execute Flux queries with InfluxDB and Chronograf v1.7+.
There are multiple ways to execute queries with InfluxDB.
This guide covers the different options:
1. [Data Explorer](#data-explorer)
@ -18,7 +18,7 @@ This guide covers the different options:
5. [InfluxDB API](#influxdb-api)
## Data Explorer
Flux queries can be built, executed, and visualized in InfluxDB UI's Data Explorer.
Queries can be built, executed, and visualized in InfluxDB UI's Data Explorer.
![Data Explorer with Flux](/img/flux-data-explorer.png)
@ -31,10 +31,10 @@ influx repl --org org-name
```
## Influx query command
You can pass Flux queries to the [`influx query` command](/v2.0/reference/cli/influx/query)
You can pass queries to the [`influx query` command](/v2.0/reference/cli/influx/query)
as either a file or raw Flux via stdin.
###### Run a Flux query from a file
###### Run a query from a file
```bash
influx query @/path/to/query.flux
```

View File

@ -1,39 +0,0 @@
---
title: Introduction to Flux
description: >
Flux is InfluxData's functional data scripting language designed for querying,
analyzing, and acting on data.
menu:
v2_0:
parent: Query data
name: Flux
weight: 1
---
Flux is InfluxData's functional data scripting language designed for querying, analyzing, and acting on data.
## Flux design principles
Flux is designed to be usable, readable, flexible, composable, testable, contributable, and shareable.
Its syntax is largely inspired by [2018's most popular scripting language](https://insights.stackoverflow.com/survey/2018#technology),
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,
and calculating the average of each window:
```js
from(bucket:"example-bucket")
|> range(start:-1h)
|> filter(fn:(r) =>
r._measurement == "cpu" and
r.cpu == "cpu-total"
)
|> aggregateWindow(every: 1m, fn: mean)
```
## Get started with Flux
The best way to familiarize yourself with Flux is to walk through creating a simple Flux query.
<div class="page-nav-btns">
<a class="btn next" href="/v2.0/query-data/flux/get-started">Get Started with Flux</a>
</div>

View File

@ -5,18 +5,36 @@ description: >
This step-by-step guide through the basics of writing a Flux query.
menu:
v2_0:
name: Get started
identifier: get-started
parent: Flux
weight: 2
name: Get started with Flux
parent: Query data
weight: 1
---
Flux is InfluxData's new functional data scripting language designed for querying,
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.
## Flux design principles
Flux is designed to be usable, readable, flexible, composable, testable, contributable, and shareable.
Its syntax is largely inspired by [2018's most popular scripting language](https://insights.stackoverflow.com/survey/2018#technology),
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,
and calculating the average of each window:
```js
from(bucket:"example-bucket")
|> range(start:-1h)
|> filter(fn:(r) =>
r._measurement == "cpu" and
r.cpu == "cpu-total"
)
|> aggregateWindow(every: 1m, fn: mean)
```
## Key concepts
Flux introduces important new concepts you should understand as you get started.
@ -51,38 +69,10 @@ are unique to each row.
## Tools for working with Flux
You have multiple [options for writing and running Flux queries](/v2.0/reference/flux/guides/execute-queries),
but as you're getting started, we recommend using the following:
### 1. Data Explorer
The InfluxDB user interface's (UI) Data Explorer makes it easy to build or write
your first Flux script and visualize the results.
![Flux in the Data Explorer](/img/flux-data-explorer,png)
The Data Explorer provides multiple ways to create Flux queries.
Toggle between the two with the button to the left of **Submit** in the Data Explorer.
![Flux Query Builder and Script Editor Toggle](/img/flux-ui-toggle.png)
#### Query Builder _(default)_
The Query Builder is a visual tool for building Flux Queries.
Select the organization and bucket from which you would like to query data.
Filter data by any columns available in the data.
Transform you data using using aggregate functions.
#### Script Editor
The Script Editor is an in-browser code editor where you can write raw Flux scripts.
### 2. influx CLI
The [`influx repl` command](/v2.0/reference/cli/influx/repl) opens an interactive
read-eval-print-loop (REPL) for querying data within an organization in InfluxDB with Flux.
```bash
influx repl --org org-name
```
The [Execute queries](/v2.0/query-data/execute-queries) guide walks through
the different tools available for querying InfluxDB with Flux.
<div class="page-nav-btns">
<a class="btn prev" href="/v2.0/query-data/flux/">Introduction to Flux</a>
<a class="btn next" href="/v2.0/query-data/flux/get-started/query-influxdb/">Query InfluxDB with Flux</a>
<a class="btn prev" href="/v2.0/query-data/">Introduction to Flux</a>
<a class="btn next" href="/v2.0/query-data/get-started/query-influxdb/">Query InfluxDB with Flux</a>
</div>

View File

@ -4,7 +4,7 @@ description: Learn the basics of using Flux to query data from InfluxDB.
menu:
v2_0:
name: Query InfluxDB
parent: get-started
parent: Get started with Flux
weight: 1
---
@ -47,7 +47,9 @@ from(bucket:"example-bucket")
|> range(start: -1h, stop: -10m)
```
> Relative ranges are relative to "now."
{{% note %}}
Relative ranges are relative to "now."
{{% /note %}}
###### Example absolute time range
```js
@ -123,6 +125,6 @@ You have now queried data from InfluxDB using Flux.
This is a barebones query that can be transformed in other ways.
<div class="page-nav-btns">
<a class="btn prev" href="/v2.0/query-data/flux/get-started/">Get started with Flux</a>
<a class="btn next" href="/v2.0/query-data/flux/get-started/transform-data/">Transform your data</a>
<a class="btn prev" href="/v2.0/query-data/get-started/">Get started with Flux</a>
<a class="btn next" href="/v2.0/query-data/get-started/transform-data/">Transform your data</a>
</div>

View File

@ -4,7 +4,7 @@ description: An introduction to the basic elements of the Flux syntax with real-
menu:
v2_0:
name: Syntax basics
parent: get-started
parent: Get started with Flux
weight: 3
---
@ -106,7 +106,7 @@ data |> someFunction() |> anotherFunction()
## Real-world application of basic syntax
This likely seems familiar if you've already been through through the other
[getting started guides](/v2.0/query-data/flux/get-started).
[getting started guides](/v2.0/query-data/get-started).
Flux's syntax is inspired by Javascript and other functional scripting languages.
As you begin to apply these basic principles in real-world use cases such as creating data stream variables,
custom functions, etc., the power of Flux and its ability to query and process data will become apparent.
@ -183,7 +183,7 @@ 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/flux/guides/custom-functions) documentation._
_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.
@ -213,5 +213,5 @@ cpuUsageUser |> topN(n:5) |> yield()
This query will return the five data points with the highest user CPU usage over the last hour.
<div class="page-nav-btns">
<a class="btn prev" href="/v2.0/query-data/flux/get-started/transform-data/">Transform your data</a>
<a class="btn prev" href="/v2.0/query-data/get-started/transform-data/">Transform your data</a>
</div>

View File

@ -4,11 +4,11 @@ description: Learn the basics of using Flux to transform data queried from Influ
menu:
v2_0:
name: Transform your data
parent: get-started
parent: Get started with Flux
weight: 2
---
When [querying data from InfluxDB](/v2.0/query-data/flux/get-started/query-influxdb),
When [querying data from InfluxDB](/v2.0/query-data/get-started/query-influxdb),
you often need to transform that data in some way.
Common examples are aggregating data into averages, downsampling data, etc.
@ -19,7 +19,7 @@ averages the `_value`s in each window, and outputs the averages as a new table.
It's important to understand how the "shape" of your data changes through each of these operations.
## Query data
Use the query built in the previous [Query data from InfluxDB](/v2.0/query-data/flux/get-started/query-influxdb)
Use the query built in the previous [Query data from InfluxDB](/v2.0/query-data/get-started/query-influxdb)
guide, but update the range to pull data from the last hour:
```js
@ -34,7 +34,7 @@ from(bucket:"example-bucket")
## Flux functions
Flux provides a number of functions that perform specific operations, transformations, and tasks.
You can also [create custom functions](/v2.0/query-data/flux/guides/custom-functions) in your Flux queries.
You can also [create custom functions](/v2.0/query-data/guides/custom-functions) in your Flux queries.
_Functions are covered in detail in the [Flux functions](/v2.0/reference/flux/functions) documentation._
A common type of function used when transforming data queried from InfluxDB is an aggregate function.
@ -166,11 +166,11 @@ and your own custom functions, but this is a good introduction into the basic sy
---
_For a deeper dive into windowing and aggregating data with example data output for each transformation,
view the [Windowing and aggregating data](/v2.0/reference/flux/guides/window-aggregate) guide._
view the [Window and aggregate data](/v2.0/query-data/guides/window-aggregate) guide._
---
<div class="page-nav-btns">
<a class="btn prev" href="/v2.0/query-data/flux/get-started/query-influxdb/">Query InfluxDB</a>
<a class="btn next" href="/v2.0/query-data/flux/get-started/syntax-basics/">Syntax basics</a>
<a class="btn prev" href="/v2.0/query-data/get-started/query-influxdb/">Query InfluxDB</a>
<a class="btn next" href="/v2.0/query-data/get-started/syntax-basics/">Syntax basics</a>
</div>

View File

@ -4,25 +4,22 @@ description: Helpful guides that walk through both common and complex tasks and
menu:
v2_0:
name: How-to guides
parent: Flux
parent: Query data
weight: 3
---
## [Different ways to execute Flux queries](/v2.0/query-data/flux/guides/execute-queries)
A guide that covers the different options for executing Flux queries with InfluxDB and Chronograf v1.7+.
## [How to window and aggregate data with Flux](/v2.0/query-data/flux/guides/window-aggregate)
## [How to window and aggregate data with Flux](/v2.0/query-data/guides/window-aggregate)
This guide walks through windowing and aggregating data with Flux and demonstrates
how data is shaped in the process.
## [How to group data with Flux](/v2.0/query-data/flux/guides/group-data)
## [How to group data with Flux](/v2.0/query-data/guides/group-data)
This guide walks through grouping data in Flux with examples of how data is shaped in the process.
## [How to join data with Flux](/v2.0/query-data/flux/guides/join)
## [How to join data with Flux](/v2.0/query-data/guides/join)
This guide walks through joining data with Flux, illustrating how joined data is output and how it can be used.
## [How to sort and limit data with Flux](/v2.0/query-data/flux/guides/sort-limit)
## [How to sort and limit data with Flux](/v2.0/query-data/guides/sort-limit)
This guide walks through sorting and limiting data with Flux.
## [Regular expressions in Flux](/v2.0/query-data/flux/guides/regular-expressions)
## [Regular expressions in Flux](/v2.0/query-data/guides/regular-expressions)
This guide walks through using regular expressions in evaluation logic in Flux functions.

View File

@ -4,7 +4,7 @@ seotitle: How to use regular expressions in Flux
description: This guide walks through using regular expressions in evaluation logic in Flux functions.
menu:
v2_0:
name: Regular expressions
name: Use regular expressions
parent: How-to guides
weight: 9
---