resolved merge conflicts with master
commit
808ac08739
|
@ -293,7 +293,7 @@ The shortcode structure is the same as above, but the shortcode names are differ
|
|||
data = from(bucket: "telegraf/autogen")
|
||||
|> range(start: -15m)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "mem" AND
|
||||
r._measurement == "mem" and
|
||||
r._field == "used_percent"
|
||||
)
|
||||
```
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# InfluxDB v2.0 Documentation
|
||||
This is the repository contains the InfluxDB v2.x documentation that will be
|
||||
accessible at [docs.influxdata.com](https://docs.influxdata.com).
|
||||
# InfluxDB 2.0 Documentation
|
||||
This repository contains the InfluxDB 2.x documentation published at [docs.influxdata.com](https://docs.influxdata.com).
|
||||
|
||||
## Contributing
|
||||
We welcome and encourage community contributions to the InfluxData See our [Contribution guidelines](CONTRIBUTING.md) for information
|
||||
about contributing to the InfluxData documentation.
|
||||
We welcome and encourage community contributions. For information about contributing to the InfluxData documentation, see [Contribution guidelines](CONTRIBUTING.md).
|
||||
|
||||
## Run the docs locally
|
||||
The InfluxData documentation uses [Hugo](https://gohugo.io/), a static site
|
||||
|
|
|
@ -8,7 +8,8 @@ menu:
|
|||
name: Get started with InfluxDB Cloud
|
||||
|
||||
---
|
||||
{{< cloud-name >}} is a fully managed and hosted version of the InfluxDB 2.x API. To get started, complete the tasks below.
|
||||
{{< cloud-name >}} is a fully managed and hosted version of the [InfluxDB v2 API](/v2.0/reference/api/).
|
||||
To get started, complete the tasks below.
|
||||
|
||||
{{% cloud-msg %}}
|
||||
The InfluxDB v2.0 alpha documentation linked to in this article also applies to {{< cloud-name "short" >}} unless otherwise specified.
|
||||
|
|
|
@ -14,19 +14,19 @@ weight: 101
|
|||
---
|
||||
|
||||
Select **Quick Start** in the last step of the InfluxDB user interface's (UI)
|
||||
[setup process](/v2.0/get-started/#setup-influxdb) to quickly start collecting data with InfluxDB.
|
||||
[setup process](/v2.0/get-started/#set-up-influxdb) to quickly start collecting data with InfluxDB.
|
||||
Quick Start creates a data scraper that collects metrics from the InfluxDB `/metrics` endpoint.
|
||||
The scraped data provides a robust dataset of internal InfluxDB metrics that you can query, visualize, and process.
|
||||
|
||||
## Use Quick Start to collect InfluxDB metrics
|
||||
After [initializing InfluxDB v2.0](/v2.0/get-started/#setup-influxdb),
|
||||
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/collect-data/scrape-data/).
|
||||
The target URL points to the `/metrics` HTTP endpoint of your local InfluxDB instance (e.g. `http://localhost:9999/metrics`),
|
||||
which outputs internal InfluxDB metrics in the [Prometheus data format](https://prometheus.io/docs/instrumenting/exposition_formats/).
|
||||
It stores the scraped metrics in the bucket created during the [initial setup process](/v2.0/get-started/#setup-influxdb).
|
||||
It stores the scraped metrics in the bucket created during the [initial setup process](/v2.0/get-started/#set-up-influxdb).
|
||||
|
||||
The following message briefly appears in the UI:
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ for using Telegraf with InfluxDB v2.0._
|
|||
## Start Telegraf
|
||||
|
||||
### Configure your API token as an environment variable
|
||||
Requests to the InfluxDB v2.0 API must include an authentication token.
|
||||
Requests to the [InfluxDB v2 API](/v2.0/reference/api/) must include an authentication token.
|
||||
A token identifies specific permissions to the InfluxDB instance.
|
||||
|
||||
Define the `INFLUX_TOKEN` environment variable using your token.
|
||||
_For information about viewing tokens, see [View tokens](/v2.0/users/tokens/view-tokens/)._
|
||||
_For information about viewing tokens, see [View tokens](/v2.0/security/tokens/view-tokens/)._
|
||||
|
||||
```sh
|
||||
export INFLUX_TOKEN=YourAuthenticationToken
|
||||
|
|
|
@ -38,7 +38,7 @@ _By default, InfluxDB runs on port `9999`._
|
|||
|
||||
##### token
|
||||
Your InfluxDB v2.0 authorization token.
|
||||
For information about viewing tokens, see [View tokens](/v2.0/users/tokens/view-tokens/).
|
||||
For information about viewing tokens, see [View tokens](/v2.0/security/tokens/view-tokens/).
|
||||
|
||||
{{% note %}}
|
||||
#### Avoid storing tokens in plain text
|
||||
|
|
|
@ -33,7 +33,7 @@ This is a paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nu
|
|||
data = from(bucket: "telegraf/autogen")
|
||||
|> range(start: -15m)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "mem" AND
|
||||
r._measurement == "mem" and
|
||||
r._field == "used_percent"
|
||||
)
|
||||
```
|
||||
|
@ -442,7 +442,7 @@ This is a paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nu
|
|||
data = from(bucket: "telegraf/autogen")
|
||||
|> range(start: -15m)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "mem" AND
|
||||
r._measurement == "mem" and
|
||||
r._field == "used_percent"
|
||||
)
|
||||
```
|
||||
|
|
|
@ -29,17 +29,22 @@ Download InfluxDB v2.0 alpha for macOS.
|
|||
|
||||
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.9_darwin_amd64.tar.gz" download>InfluxDB v2.0 alpha (macOS)</a>
|
||||
|
||||
### Place the executables in your $PATH
|
||||
Unpackage the downloaded archive and place the `influx` and `influxd` executables in your system `$PATH`.
|
||||
### Unpackage the InfluxDB binaries
|
||||
Unpackage the downloaded archive.
|
||||
|
||||
_**Note:** The following commands are examples. Adjust the file paths to your own needs._
|
||||
|
||||
```sh
|
||||
# Unpackage contents to the current working directory
|
||||
gunzip -c ~/Downloads/influxdb_2.0.0-alpha.9_darwin_amd64.tar.gz | tar xopf -
|
||||
gunzip -c ~/Downloads/influxdb_2.0.0-alpha.8_darwin_amd64.tar.gz | tar xopf -
|
||||
```
|
||||
|
||||
# Copy the influx and influxd binary to your $PATH
|
||||
sudo cp influxdb_2.0.0-alpha.9_darwin_amd64/{influx,influxd} /usr/local/bin/
|
||||
If you choose, you can place `influx` and `influxd` in your `$PATH`.
|
||||
You can also prefix the executables with `./` to run then in place.
|
||||
|
||||
```sh
|
||||
# (Optional) Copy the influx and influxd binary to your $PATH
|
||||
sudo cp influxdb_2.0.0-alpha.8_darwin_amd64/{influx,influxd} /usr/local/bin/
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
|
@ -50,7 +55,8 @@ If you rename the binaries, all references to `influx` and `influxd` in this doc
|
|||
{{% /note %}}
|
||||
|
||||
### Networking ports
|
||||
By default, InfluxDB uses TCP port `9999` for client-server communication over InfluxDB’s HTTP API.
|
||||
By default, InfluxDB uses TCP port `9999` for client-server communication over
|
||||
the [InfluxDB HTTP API](/v2.0/reference/api/).
|
||||
|
||||
## Start InfluxDB
|
||||
Start InfluxDB by running the `influxd` daemon:
|
||||
|
@ -108,7 +114,8 @@ If you rename the binaries, all references to `influx` and `influxd` in this doc
|
|||
{{% /note %}}
|
||||
|
||||
### Networking ports
|
||||
By default, InfluxDB uses TCP port `9999` for client-server communication over InfluxDB’s HTTP API.
|
||||
By default, InfluxDB uses TCP port `9999` for client-server communication over
|
||||
the [InfluxDB HTTP API](/v2.0/reference/api/).
|
||||
|
||||
## Start InfluxDB
|
||||
Start InfluxDB by running the `influxd` daemon:
|
||||
|
@ -141,7 +148,8 @@ influxd --reporting-disabled
|
|||
{{% tab-content %}}
|
||||
### Download and run InfluxDB v2.0 alpha
|
||||
Use `docker run` to download and run the InfluxDB v2.0 alpha Docker image.
|
||||
Expose port `9999`, which InfluxDB uses for client-server communication over its HTTP API.
|
||||
Expose port `9999`, which InfluxDB uses for client-server communication over
|
||||
the [InfluxDB HTTP API](/v2.0/reference/api/).
|
||||
|
||||
```sh
|
||||
docker run --name influxdb -p 9999:9999 quay.io/influxdb/influxdb:2.0.0-alpha
|
||||
|
@ -213,7 +221,7 @@ use one of the following methods to provide your [authentication token](/v2.0/us
|
|||
3. Store your token in `~/.influxdbv2/credentials`.
|
||||
_The content of the `credentials` file should be only your token._
|
||||
|
||||
_See [View tokens](/v2.0/users/tokens/view-tokens/) for information about
|
||||
_See [View tokens](/v2.0/security/tokens/view-tokens/) for information about
|
||||
retrieving authentication tokens._
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -33,3 +33,25 @@ influx org find
|
|||
Filtering options such as filtering by name or ID are available.
|
||||
See the [`influx org find` documentation](/v2.0/reference/cli/influx/org/find)
|
||||
for information about other available flags.
|
||||
|
||||
## View your organization ID
|
||||
Use the InfluxDB UI or `influx` CLI to view your organization ID.
|
||||
|
||||
### Organization ID in the UI
|
||||
After logging in to the InfluxDB UI, your organization ID appears in the URL.
|
||||
|
||||
<pre class="highlight">
|
||||
http://localhost:9999/orgs/<span class="bp" style="font-weight:bold;margin:0 .15rem">03a2bbf46249a000</span>/...
|
||||
</pre>
|
||||
|
||||
|
||||
### Organization ID in the CLI
|
||||
Use [`influx org find`](#view-organizations-using-the-influx-cli) to view your organization ID.
|
||||
|
||||
```sh
|
||||
> influx org find
|
||||
|
||||
ID Name
|
||||
03a2bbf46249a000 org-1
|
||||
03ace3a859669000 org-2
|
||||
```
|
||||
|
|
|
@ -64,7 +64,7 @@ the required time range and any relevant filters.
|
|||
data = from(bucket: "telegraf/default")
|
||||
|> range(start: -task.every)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "mem" AND
|
||||
r._measurement == "mem" and
|
||||
r.host == "myHost"
|
||||
)
|
||||
```
|
||||
|
@ -113,7 +113,10 @@ to send the transformed data to another bucket:
|
|||
```
|
||||
|
||||
{{% note %}}
|
||||
You cannot write to the same bucket you are reading from.
|
||||
#### Important notes
|
||||
- You cannot write to the same bucket you are reading from.
|
||||
- In order to write data into InfluxDB, you must have `_time`, `_measurement`,
|
||||
`_field`, and `_value` columns.
|
||||
{{% /note %}}
|
||||
|
||||
## Full example task script
|
||||
|
@ -134,7 +137,7 @@ option task = {
|
|||
data = from(bucket: "telegraf/default")
|
||||
|> range(start: -task.every)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "mem" AND
|
||||
r._measurement == "mem" and
|
||||
r.host == "myHost"
|
||||
)
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ data = from(bucket: "example-bucket") |> range(start: -10m) # ...
|
|||
```
|
||||
|
||||
## InfluxDB API
|
||||
The [InfluxDB v2 API](/v2.0/reference/api) provides a programmatic
|
||||
interface for all interactions with InfluxDB.
|
||||
Query InfluxDB through the `/api/v2/query` endpoint.
|
||||
Queried data is returned in annotated CSV format.
|
||||
|
||||
|
@ -61,7 +63,7 @@ In your request, set the following:
|
|||
- `accept` header to `application/csv`.
|
||||
- `content-type` header to `application/vnd.flux`.
|
||||
|
||||
This allows you to POST the Flux query in plain text and receive the annotated CSV response.
|
||||
This lets you POST the Flux query in plain text and receive the annotated CSV response.
|
||||
|
||||
Below is an example `curl` command that queries InfluxDB:
|
||||
|
||||
|
|
|
@ -0,0 +1,256 @@
|
|||
---
|
||||
title: Create custom aggregate functions
|
||||
description: Create your own custom aggregate functions in Flux using the `reduce()` function.
|
||||
v2.0/tags: [functions, custom, flux, aggregates]
|
||||
menu:
|
||||
v2_0:
|
||||
name: Custom aggregate functions
|
||||
parent: Create custom functions
|
||||
weight: 301
|
||||
---
|
||||
|
||||
To aggregate your data, use the Flux
|
||||
[built-in aggregate functions](/v2.0/reference/flux/functions/built-in/transformations/aggregates/)
|
||||
or create custom aggregate functions using the
|
||||
[`reduce()`function](/v2.0/reference/flux/functions/built-in/transformations/aggregates/reduce/).
|
||||
|
||||
## Aggregate function characteristics
|
||||
Aggregate functions all have the same basic characteristics:
|
||||
|
||||
- They operate on individual input tables and transform all records into a single record.
|
||||
- The output table has the same [group key](/v2.0/query-data/get-started/#group-keys) as the input table.
|
||||
|
||||
## How reduce() works
|
||||
The `reduce()` function operates on one row at a time using the function defined in
|
||||
the [`fn` parameter](/v2.0/reference/flux/functions/built-in/transformations/aggregates/reduce/#fn).
|
||||
The `fn` function maps keys to specific values using two [objects](/v2.0/query-data/get-started/syntax-basics/#objects)
|
||||
specified by the following parameters:
|
||||
|
||||
| Parameter | Description |
|
||||
|:---------: |:----------- |
|
||||
| `r` | An object that represents the row or record. |
|
||||
| `accumulator` | An object that contains values used in each row's aggregate calculation. |
|
||||
|
||||
{{% note %}}
|
||||
The `reduce()` function's [`identity` parameter](/v2.0/reference/flux/functions/built-in/transformations/aggregates/reduce/#identity)
|
||||
defines the initial `accumulator` object.
|
||||
{{% /note %}}
|
||||
|
||||
### Example reduce() function
|
||||
The following example `reduce()` function produces a sum and product of all values
|
||||
in an input table.
|
||||
|
||||
```js
|
||||
|> reduce(fn: (r, accumulator) => ({
|
||||
sum: r._value + accumulator.sum,
|
||||
product: r._value * accumulator.product
|
||||
})
|
||||
identity: {sum: 0.0, product: 1.0}
|
||||
)
|
||||
```
|
||||
|
||||
To illustrate how this function works, take this simplified table for example:
|
||||
|
||||
```txt
|
||||
_time _value
|
||||
----------------------- -------
|
||||
2019-04-23T16:10:49.00Z 1.6
|
||||
2019-04-23T16:10:59.00Z 2.3
|
||||
2019-04-23T16:11:09.00Z 0.7
|
||||
2019-04-23T16:11:19.00Z 1.2
|
||||
2019-04-23T16:11:29.00Z 3.8
|
||||
```
|
||||
|
||||
###### Input objects
|
||||
The `fn` function uses the data in the first row to define the `r` object.
|
||||
It defines the `accumulator` object using the `identity` parameter.
|
||||
|
||||
```js
|
||||
r = { _time: 2019-04-23T16:10:49.00Z, _value: 1.6 }
|
||||
accumulator = { sum : 0.0, product : 1.0 }
|
||||
```
|
||||
|
||||
###### Key mappings
|
||||
It then uses the `r` and `accumulator` objects to populate values in the key mappings:
|
||||
```js
|
||||
// sum: r._value + accumulator.sum
|
||||
sum: 1.6 + 0.0
|
||||
|
||||
// product: r._value * accumulator.product
|
||||
product: 1.6 * 1.0
|
||||
```
|
||||
|
||||
###### Output object
|
||||
This produces an output object with the following key value pairs:
|
||||
|
||||
```js
|
||||
{ sum: 1.6, product: 1.6 }
|
||||
```
|
||||
|
||||
The function then processes the next row using this **output object** as the `accumulator`.
|
||||
|
||||
{{% note %}}
|
||||
Because `reduce()` uses the output object as the `accumulator` when processing the next row,
|
||||
keys mapped in the `fn` function must match keys in the `identity` and `accumulator` objects.
|
||||
{{% /note %}}
|
||||
|
||||
###### Processing the next row
|
||||
```js
|
||||
// Input objects for the second row
|
||||
r = { _time: 2019-04-23T16:10:59.00Z, _value: 2.3 }
|
||||
accumulator = { sum : 1.6, product : 1.6 }
|
||||
|
||||
// Key mappings for the second row
|
||||
sum: 2.3 + 1.6
|
||||
product: 2.3 * 1.6
|
||||
|
||||
// Output object of the second row
|
||||
{ sum: 3.9, product: 3.68 }
|
||||
```
|
||||
|
||||
It then uses the new output object as the `accumulator` for the next row.
|
||||
This cycle continues until all rows in the table are processed.
|
||||
|
||||
##### Final output object and table
|
||||
After all records in the table are processed, `reduce()` uses the final output object
|
||||
to create a transformed table with one row and columns for each mapped key.
|
||||
|
||||
```js
|
||||
// Final output object
|
||||
{ sum: 9.6, product: 11.74656 }
|
||||
|
||||
// Output table
|
||||
sum product
|
||||
---- ---------
|
||||
9.6 11.74656
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### What happened to the \_time column?
|
||||
The `reduce()` function only keeps columns that are:
|
||||
|
||||
1. Are part of the input table's [group key](/v2.0/query-data/get-started/#group-keys).
|
||||
2. Explicitly mapped in the `fn` function.
|
||||
|
||||
It drops all other columns.
|
||||
Because `_time` is not part of the group key and is not mapped in the `fn` function,
|
||||
it isn't included in the output table.
|
||||
{{% /note %}}
|
||||
|
||||
## Custom aggregate function examples
|
||||
To create custom aggregate functions, use principles outlined in
|
||||
[Creating custom functions](/v2.0/query-data/guides/custom-functions)
|
||||
and the `reduce()` function to aggregate rows in each input table.
|
||||
|
||||
### Create a custom average function
|
||||
This example illustrates how to create a function that averages values in a table.
|
||||
_This is meant for demonstration purposes only.
|
||||
The built-in [`mean()` function](/v2.0/reference/flux/functions/built-in/tranformations/aggregates/mean/)
|
||||
does the same thing and is much more performant._
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[Comments](#)
|
||||
[No Comments](#)
|
||||
{{% /code-tabs %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
|
||||
```js
|
||||
average = (tables=<-, outputField="average") =>
|
||||
tables
|
||||
|> reduce(
|
||||
// Define the initial accumulator object
|
||||
identity: {
|
||||
count: 1.0,
|
||||
sum: 0.0,
|
||||
avg: 0.0
|
||||
}
|
||||
fn: (r, accumulator) => ({
|
||||
// Increment the counter on each reduce loop
|
||||
count: accumulator.count + 1.0,
|
||||
// Add the _value to the existing sum
|
||||
sum: accumulator.sum + r._value,
|
||||
// Divide the existing sum by the existing count for a new average
|
||||
avg: accumulator.sum / accumulator.count
|
||||
})
|
||||
)
|
||||
// Drop the sum and the count columns since they are no longer needed
|
||||
|> drop(columns: ["sum", "count"])
|
||||
// Set the _field column of the output table to to the value
|
||||
// provided in the outputField parameter
|
||||
|> set(key: "_field", value: outputField)
|
||||
// Rename avg column to _value
|
||||
|> rename(columns: {avg: "_value"})
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```js
|
||||
average = (tables=<-, outputField="average") =>
|
||||
tables
|
||||
|> reduce(
|
||||
identity: {
|
||||
count: 1.0,
|
||||
sum: 0.0,
|
||||
avg: 0.0
|
||||
}
|
||||
fn: (r, accumulator) => ({
|
||||
count: accumulator.count + 1.0,
|
||||
sum: accumulator.sum + r._value,
|
||||
avg: accumulator.sum / accumulator.count
|
||||
})
|
||||
)
|
||||
|> drop(columns: ["sum", "count"])
|
||||
|> set(key: "_field", value: outputField)
|
||||
|> rename(columns: {avg: "_value"})
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
### Aggregate multiple columns
|
||||
Built-in aggregate functions only operate on one column.
|
||||
Use `reduce()` to create a custom aggregate function that aggregates multiple columns.
|
||||
|
||||
The following function expects input tables to have `c1_value` and `c2_value`
|
||||
columns and generates an average for each.
|
||||
|
||||
```js
|
||||
multiAvg = (tables=<-) =>
|
||||
tables
|
||||
|> reduce(
|
||||
identity: {
|
||||
count: 1.0,
|
||||
c1_sum: 0.0,
|
||||
c1_avg: 0.0,
|
||||
c2_sum: 0.0,
|
||||
c2_avg: 0.0
|
||||
}
|
||||
fn: (r, accumulator) => ({
|
||||
count: accumulator.count + 1.0,
|
||||
c1_sum: accumulator.c1_sum + r.c1_value,
|
||||
c1_avg: accumulator.c1_sum / accumulator.count,
|
||||
c2_sum: accumulator.c2_sum + r.c2_value,
|
||||
c2_avg: accumulator.c2_sum / accumulator.count
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
### Aggregate gross and net profit
|
||||
Use `reduce()` to create a function that aggregates gross and net profit.
|
||||
This example expects `profit` and `expenses` columns in the input tables.
|
||||
|
||||
```js
|
||||
profitSummary = (tables=<-) =>
|
||||
tables
|
||||
|> reduce(
|
||||
identity: {
|
||||
gross: 0.0,
|
||||
net: 0.0
|
||||
}
|
||||
fn: (r, accumulator) => ({
|
||||
gross: accumulator.gross + r.profit,
|
||||
net: accumulator.net + r.profit - r.expenses
|
||||
})
|
||||
)
|
||||
```
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: InfluxDB v2 API
|
||||
description: >
|
||||
The InfluxDB v2 API provides a programmatic interface for interactions with InfluxDB.
|
||||
Access the InfluxDB API using the `/api/v2/` endpoint.
|
||||
menu: v2_0_ref
|
||||
weight: 2
|
||||
v2.0/tags: [api]
|
||||
---
|
||||
|
||||
The InfluxDB v2 API provides a programmatic interface for interactions with InfluxDB.
|
||||
Access the InfluxDB API using the `/api/v2/` endpoint.
|
||||
|
||||
## Authentication
|
||||
InfluxDB uses [authentication tokens](/v2.0/security/tokens/) to authorize API requests.
|
||||
Include your authentication token as an `Authorization` header in each request.
|
||||
|
||||
```sh
|
||||
curl --request GET \
|
||||
--url http://localhost:9999/api/v2/ \
|
||||
--header 'Authorization: Token YOURAUTHTOKEN'
|
||||
```
|
||||
|
||||
## View Influx v2 API Documentation
|
||||
Full InfluxDB v2 API documentation is built into the `influxd` service.
|
||||
To view the API documentation, [start InfluxDB](/v2.0/get-started/#start-influxdb)
|
||||
and visit the `/docs` endpoint in a browser.
|
||||
|
||||
<a class="btn" href="http://localhost:9999/docs" target="\_blank">localhost:9999/docs</a>
|
|
@ -38,7 +38,7 @@ with each `influx` command, use one of the following methods to store your token
|
|||
_**Note:** If you [set up InfluxDB using the CLI](/v2.0/reference/cli/influx/setup),
|
||||
InfluxDB stores your token in the credentials files automatically._
|
||||
|
||||
_See [View tokens](/v2.0/users/tokens/view-tokens/) for information about
|
||||
_See [View tokens](/v2.0/security/tokens/view-tokens/) for information about
|
||||
retrieving authentication tokens._
|
||||
{{% /note %}}
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ weight: 401
|
|||
|
||||
The `to()` function writes data to an **InfluxDB v2.0** bucket.
|
||||
|
||||
_**Function type:** Output_
|
||||
_**Output data type:** Object_
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
to(
|
||||
|
@ -39,6 +38,18 @@ to(
|
|||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
### Output data requirements
|
||||
The `to()` function converts output data into line protocol and writes it to InfluxDB.
|
||||
Line protocol requires each record to have a timestamp, a measurement, a field, and a value.
|
||||
All output data must include the following columns:
|
||||
|
||||
- `_time`
|
||||
- `_measurement`
|
||||
- `_field`
|
||||
- `_value`
|
||||
{{% /note %}}
|
||||
|
||||
## Parameters
|
||||
{{% note %}}
|
||||
`bucket` OR `bucketID` is **required**.
|
||||
|
|
|
@ -11,6 +11,7 @@ weight: 501
|
|||
---
|
||||
|
||||
The `distinct()` function returns the unique values for a given column.
|
||||
The `_value` of each output record is set to the distinct value in the specified column.
|
||||
`null` is considered its own distinct value if it is present.
|
||||
|
||||
_**Function type:** Selector_
|
||||
|
|
|
@ -11,6 +11,7 @@ weight: 501
|
|||
---
|
||||
|
||||
The `unique()` function returns all records containing unique values in a specified column.
|
||||
Group keys, record columns, and values are **not** modified.
|
||||
|
||||
_**Function type:** Selector_
|
||||
_**Output data type:** Object_
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
title: Manage security and authorization
|
||||
description: >
|
||||
Security, access control, and sensitive secret handling are incredibly important
|
||||
when handling any sort of sensitive data.
|
||||
This section provides information about managing the security of your InfluxDB instance.
|
||||
weight: 12
|
||||
menu:
|
||||
v2_0:
|
||||
name: Security & authorization
|
||||
v2.0/tags: [security, authentication]
|
||||
---
|
||||
|
||||
Security, access control, and sensitive secret handling are incredibly important
|
||||
when handling any sort of sensitive data.
|
||||
This section provides information about managing the security of your InfluxDB instance.
|
||||
|
||||
{{< children >}}
|
|
@ -1,17 +1,19 @@
|
|||
---
|
||||
title: Manage tokens
|
||||
seotitle: Manage tokens in InfluxDB
|
||||
title: Manage authentication tokens
|
||||
seotitle: Manage authentication tokens in InfluxDB
|
||||
description: Manage authentication tokens in InfluxDB using the InfluxDB UI or the influx CLI.
|
||||
v2.0/tags: [tokens, authentication]
|
||||
aliases:
|
||||
- /v2.0/users/tokens
|
||||
v2.0/tags: [tokens, authentication, security]
|
||||
menu:
|
||||
v2_0:
|
||||
name: Manage tokens
|
||||
parent: Manage users
|
||||
weight: 105
|
||||
parent: Security & authorization
|
||||
weight: 101
|
||||
---
|
||||
|
||||
InfluxDB ensures secure interaction between users and data through the use of **authentication tokens**.
|
||||
A token identifies InfluxDB permissions.
|
||||
A token belongs to an organization and identifies InfluxDB permissions within the organization.
|
||||
|
||||
The following articles provide information about managing authentication tokens.
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
title: Create a token
|
||||
seotitle: Create an authentication token in InfluxDB
|
||||
description: Create an authentication token in InfluxDB using the InfluxDB UI or the `influx` CLI.
|
||||
aliases:
|
||||
- /v2.0/users/tokens/create-token/
|
||||
menu:
|
||||
v2_0:
|
||||
name: Create a token
|
|
@ -2,6 +2,8 @@
|
|||
title: Delete a token
|
||||
seotitle: Delete an authentication token from InfluxDB
|
||||
description: Delete an authentication token from InfluxDB using the InfluxDB UI or the `influx` CLI.
|
||||
aliases:
|
||||
- /v2.0/users/tokens/delete-token
|
||||
menu:
|
||||
v2_0:
|
||||
name: Delete a token
|
|
@ -1,7 +1,9 @@
|
|||
---
|
||||
title: Update a token
|
||||
seotitle: Update authentication tokens in InfluxDB
|
||||
description: Update authentication tokens' descriptions in InfluxDB using the InfluxDB UI.
|
||||
description: Update authentication tokens' descriptions in InfluxDB using the InfluxDB UI
|
||||
aliases:
|
||||
- /v2.0/users/tokens/update-tokens
|
||||
menu:
|
||||
v2_0:
|
||||
name: Update a token
|
|
@ -2,6 +2,8 @@
|
|||
title: View tokens
|
||||
seotitle: View authentication tokens in InfluxDB
|
||||
description: View authentication tokens in InfluxDB using the InfluxDB UI or the `influx` CLI.
|
||||
aliases:
|
||||
- /v2.0/users/tokens/view-tokens
|
||||
menu:
|
||||
v2_0:
|
||||
name: View tokens
|
|
@ -0,0 +1,129 @@
|
|||
---
|
||||
title: Store secrets in Vault
|
||||
description: Manage authentication tokens in InfluxDB using the InfluxDB UI or the influx CLI.
|
||||
v2.0/tags: [tokens, security]
|
||||
menu:
|
||||
v2_0:
|
||||
parent: Security & authorization
|
||||
weight: 102
|
||||
---
|
||||
|
||||
[Vault](https://www.vaultproject.io/) secures, stores, and tightly controls access
|
||||
to tokens, passwords, certificates, and other sensitive secrets.
|
||||
Store sensitive secrets in Vault using the InfluxDB built-in Vault integration.
|
||||
|
||||
{{% note %}}
|
||||
When not using Vault, secrets are Base64-encoded and stored in the InfluxDB embedded key value store,
|
||||
[BoltDB](https://github.com/boltdb/bolt).
|
||||
{{% /note %}}
|
||||
|
||||
## Start a Vault server
|
||||
Start a Vault server and ensure InfluxDB has network access to the server.
|
||||
The following links provide information about running Vault in both development and production:
|
||||
|
||||
- [Install Vault](https://learn.hashicorp.com/vault/getting-started/install)
|
||||
- [Start a Vault dev server](https://learn.hashicorp.com/vault/getting-started/dev-server)
|
||||
- [Deploy Vault](https://learn.hashicorp.com/vault/getting-started/deploy)
|
||||
|
||||
For this example, install Vault on your local machine and start a Vault dev server.
|
||||
|
||||
```sh
|
||||
vault server -dev
|
||||
```
|
||||
|
||||
## Define Vault environment variables
|
||||
Use [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 environment variables
|
||||
- `VAULT_ADDR`: The API address of your Vault server _(provided in the Vault server output)_.
|
||||
- `VAULT_TOKEN`: The [Vault token](https://learn.hashicorp.com/vault/getting-started/authentication)
|
||||
required to access your Vault server.
|
||||
|
||||
_Your Vault server configuration may require other environment variables._
|
||||
|
||||
```sh
|
||||
export VAULT_ADDR='http://127.0.0.1:8200' VAULT_TOKEN='s.0X0XxXXx0xXxXXxxxXxXxX0x'
|
||||
```
|
||||
|
||||
## Start InfluxDB
|
||||
Start the [`influxd` service](/v2.0/reference/cli/influxd/) with the `--secret-store`
|
||||
option set to `vault`.
|
||||
|
||||
```bash
|
||||
influxd --secret-store vault
|
||||
```
|
||||
|
||||
## Test Vault storage
|
||||
With Vault and InfluxDB servers running, use the InfluxDB API to test Vault:
|
||||
|
||||
{{% note %}}
|
||||
Replace `<org-id>` with your [organization ID](/v2.0/organizations/view-orgs/#view-your-organization-id)
|
||||
and `YOURAUTHTOKEN` with your [InfluxDB authentication token](/v2.0/security/tokens/).
|
||||
{{% /note %}}
|
||||
|
||||
##### Retrieve an organization's secrets
|
||||
```sh
|
||||
curl --request GET \
|
||||
--url http://localhost:9999/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'authorization: Token YOURAUTHTOKEN'
|
||||
|
||||
# should return
|
||||
# {
|
||||
# "links": {
|
||||
# "org": "/api/v2/orgs/031c8cbefe101000",
|
||||
# "secrets": "/api/v2/orgs/031c8cbefe101000/secrets"
|
||||
# },
|
||||
# "secrets": []
|
||||
# }
|
||||
```
|
||||
|
||||
##### Add secrets to an organization
|
||||
```sh
|
||||
curl --request PATCH \
|
||||
--url http://localhost:9999/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'authorization: Token YOURAUTHTOKEN' \
|
||||
--header 'content-type: application/json' \
|
||||
--data '{
|
||||
"foo": "bar",
|
||||
"hello": "world"
|
||||
}'
|
||||
|
||||
# should return 204 no content
|
||||
```
|
||||
|
||||
##### Retrieve the added secrets
|
||||
```bash
|
||||
curl --request GET \
|
||||
--url http://localhost:9999/api/v2/orgs/<org-id>/secrets \
|
||||
--header 'authorization: Token YOURAUTHTOKEN'
|
||||
|
||||
# should return
|
||||
# {
|
||||
# "links": {
|
||||
# "org": "/api/v2/orgs/031c8cbefe101000",
|
||||
# "secrets": "/api/v2/orgs/031c8cbefe101000/secrets"
|
||||
# },
|
||||
# "secrets": [
|
||||
# "foo",
|
||||
# "hello"
|
||||
# ]
|
||||
# }
|
||||
```
|
||||
|
||||
## Vault secrets storage
|
||||
For each organization, InfluxDB creates a [secrets engine](https://learn.hashicorp.com/vault/getting-started/secrets-engines)
|
||||
using the following pattern:
|
||||
|
||||
```
|
||||
/secret/data/<org-id>
|
||||
```
|
||||
|
||||
Secrets are stored in Vault as key value pairs in their respective secrets engines.
|
||||
|
||||
```
|
||||
/secret/data/031c8cbefe101000 ->
|
||||
this_key: foo
|
||||
that_key: bar
|
||||
a_secret: key
|
||||
```
|
|
@ -6,12 +6,12 @@ v2.0/tags: [users, authentication]
|
|||
menu:
|
||||
v2_0:
|
||||
name: Manage users
|
||||
weight: 12
|
||||
weight: 11
|
||||
---
|
||||
|
||||
Users are those with access to InfluxDB.
|
||||
In order to access any data, a user must be added as a member of an organization.
|
||||
All users have unique authentication tokens with specific permissions used to grant them access to data within InfluxDB.
|
||||
To grant a user permission to access data, add them as a [member of an organization](/v2.0/organizations/members/)
|
||||
and provide them with an [authentication token](/v2.0/security/tokens/).
|
||||
|
||||
The following articles walk through managing users.
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ making it easy to interact with your dashboard cells and explore your data.
|
|||
Variables are scoped by organization.
|
||||
|
||||
## Use dashboard variables
|
||||
Both [predefined dashboard variables](#predefined-dashboard-variables) and [custom dashboard variables](#manage-custom-variables)
|
||||
Both [predefined dashboard variables](#predefined-dashboard-variables) and [custom dashboard variables](#custom-dashboard-variables)
|
||||
are stored in a `v` object associated with each dashboard.
|
||||
Reference each variable using dot-notation (e.g. `v.variableName`).
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ can be created from the Data Explorer.
|
|||
{{< nav-icon "data-explorer" >}}
|
||||
|
||||
2. Click **Script Editor** on the lower right.
|
||||
3. Build the query for your variable using the [Table visualization type](v2.0/visualize-data/visualization-types/#table) or enable the **View Raw Data** option.
|
||||
3. Build the query for your variable using the [Table visualization type](/v2.0/visualize-data/visualization-types/#table) or enable the **View Raw Data** option.
|
||||
4. Click **Save As** in the upper right.
|
||||
5. In the window that appears, select **Variable**.
|
||||
6. Enter a name for your variable in the **Name** field.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
{{ $currentVersion := (index (findRE "[^/]+.*?" .RelPermalink) 0) .RelPermalink }}
|
||||
{{ $stableVersion := $.Site.Data.versions.stable_version }}
|
||||
{{ $canonicalURL := print (replaceRE `\/$` "" .Site.BaseURL) (replaceRE "[^/]+.*?[0]" $stableVersion .RelPermalink) }}
|
||||
|
||||
{{ if not (eq $currentVersion $stableVersion) }}
|
||||
<link rel="canonical" href="{{ $canonicalURL }}" />
|
||||
{{ end }}
|
||||
<link rel="canonical" href="{{ $canonicalURL }}" />
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
{{ $currentPage := . }}
|
||||
{{ $currentVersion := (index (findRE "[^/]+.*?" .RelPermalink) 0) }}
|
||||
<aside class="sidebar">
|
||||
|
||||
<div class="sidebar-toggle" onclick="toggle_sidebar('sidebar-closed');return false;"><a href="#"></a></div>
|
||||
|
||||
<div class="search-and-nav-toggle">
|
||||
<div class="sidebar--search">
|
||||
<input class="sidebar--search-field"
|
||||
|
@ -21,238 +19,22 @@
|
|||
<span class="toggle-hamburger"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<ul id="nav-tree">
|
||||
|
||||
{{ $menuID := replaceRE "[.]" "_" $currentVersion }}
|
||||
{{ $mainMenu := (index .Site.Menus (replaceRE "[.]" "_" $currentVersion)) }}
|
||||
{{ $cloudMenu := (index .Site.Menus (print (replaceRE "[.]" "_" $currentVersion) "_cloud")) }}
|
||||
{{ $refMenu := (index .Site.Menus (print (replaceRE "[.]" "_" $currentVersion) "_ref")) }}
|
||||
|
||||
{{ range (index .Site.Menus $menuID) }}
|
||||
<!-- Nested Navigation -->
|
||||
<li class="nav-category {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
|
||||
<!-- Begin nested block -->
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
<!-- To add more nested layers, copy the nested block and paste it here -->
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
<!-- End nested block -->
|
||||
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{end}}
|
||||
<!-- Main Section -->
|
||||
{{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $mainMenu) }}
|
||||
|
||||
<!-- Cloud Section -->
|
||||
{{ $refMenuID := print (replaceRE "[.]" "_" $currentVersion) "_cloud" }}
|
||||
<h4 class="reference">{{ .Site.Data.products.cloud.shortname }}</h4>
|
||||
|
||||
{{ range (index .Site.Menus $refMenuID) }}
|
||||
<!-- Nested Reference Navigation -->
|
||||
<li class="nav-category {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
|
||||
<!-- Begin nested block -->
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
<!-- To add more nested layers, copy the nested block and paste it here -->
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
<!-- End nested block -->
|
||||
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{end}}
|
||||
{{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $cloudMenu) }}
|
||||
|
||||
<!-- Reference Section -->
|
||||
{{ $refMenuID := print (replaceRE "[.]" "_" $currentVersion) "_ref" }}
|
||||
<h4 class="reference">Reference</h4>
|
||||
|
||||
{{ range (index .Site.Menus $refMenuID) }}
|
||||
<!-- Nested Reference Navigation -->
|
||||
<li class="nav-category {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
|
||||
<!-- Begin nested block -->
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
<!-- To add more nested layers, copy the nested block and paste it here -->
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
<!-- End nested block -->
|
||||
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{end}}
|
||||
|
||||
{{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $refMenu) }}
|
||||
|
||||
</ul>
|
||||
</aside>
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
{{ $page := .page }}
|
||||
{{ $menu := .menu }}
|
||||
|
||||
{{ range $menu }}
|
||||
<li class="nav-category {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
|
||||
<!-- Begin nested block -->
|
||||
{{ if .HasChildren }}
|
||||
<ul class="children {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}">
|
||||
{{ range .Children }}
|
||||
<li class="nav-item {{ if eq $page.RelPermalink .URL }}active{{end}}">
|
||||
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($page.IsMenuCurrent .Menu .) ($page.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
<!-- To add more nested layers, copy the nested block and paste it here -->
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
<!-- End nested block -->
|
||||
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
Loading…
Reference in New Issue