Merge pull request #1017 from influxdata/query/explore-schema
Schema exploration query guide, new v1 functionspull/1070/head
commit
55297b6a3c
|
@ -9,7 +9,7 @@ menu:
|
|||
v2_0:
|
||||
name: Calculate percentages
|
||||
parent: Query with Flux
|
||||
weight: 206
|
||||
weight: 209
|
||||
aliases:
|
||||
- /v2.0/query-data/guides/manipulate-timestamps/
|
||||
related:
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
---
|
||||
title: Explore your data schema with Flux
|
||||
list_title: Explore your schema
|
||||
description: >
|
||||
Flux provides functions that let you explore the structure and schema of your
|
||||
data stored in InfluxDB.
|
||||
v2.0/tags: [schema]
|
||||
menu:
|
||||
v2_0:
|
||||
name: Explore your schema
|
||||
parent: Query with Flux
|
||||
weight: 206
|
||||
related:
|
||||
- /v2.0/reference/flux/stdlib/built-in/inputs/buckets/
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/measurements
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/tagkeys
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/tagvalues
|
||||
- /v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues
|
||||
list_code_example: |
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
// List buckets
|
||||
buckets()
|
||||
|
||||
// List measurements
|
||||
v1.measurements(bucket: "example-bucket")
|
||||
|
||||
// List field keys
|
||||
v1.fieldKeys(bucket: "example-bucket")
|
||||
|
||||
// List tag keys
|
||||
v1.tagKeys(bucket: "example-bucket")
|
||||
|
||||
// List tag values
|
||||
v1.tagValues(bucket: "example-bucket", tag: "example-tag")
|
||||
```
|
||||
---
|
||||
|
||||
Flux provides functions that let you explore the structure and schema of your
|
||||
data stored in InfluxDB.
|
||||
|
||||
- [List buckets](#list-buckets)
|
||||
- [List measurements](#list-measurements)
|
||||
- [List field keys](#list-field-keys)
|
||||
- [List tag keys](#list-tag-keys)
|
||||
- [List tag values](#list-tag-values)
|
||||
|
||||
## List buckets
|
||||
Use the [`buckets()` function](/v2.0/reference/flux/stdlib/built-in/inputs/buckets/)
|
||||
to list **buckets in your organization**.
|
||||
|
||||
```js
|
||||
buckets()
|
||||
```
|
||||
|
||||
## List measurements
|
||||
Use the [`v1.measurements()` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurements)
|
||||
to list **measurements in a bucket**.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.measurements(bucket: "example-bucket")
|
||||
```
|
||||
|
||||
## List field keys
|
||||
Use the [`v1.fieldKeys` function](/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys)
|
||||
to list **field keys in a bucket**.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.fieldKeys(bucket: "example-bucket")
|
||||
```
|
||||
|
||||
### List fields in a measurement
|
||||
Use the [`v1.measurementFieldKeys` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurementfieldkeys)
|
||||
to list **field keys in a measurement**.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.measurementFieldKeys(
|
||||
bucket: "example-bucket",
|
||||
measurement: "example-measurement"
|
||||
)
|
||||
```
|
||||
|
||||
## List tag keys
|
||||
Use the [`v1.tagKeys()` function](/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys)
|
||||
to list **tag keys in a bucket**.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.tagKeys(bucket: "example-bucket")
|
||||
```
|
||||
|
||||
### List tag keys in a measurement
|
||||
Use the [`v1.measurementTagKeys` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagkeys)
|
||||
to list **tag keys in a measurement**.
|
||||
_This function returns results from the last 30 days._
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.measurementTagKeys(
|
||||
bucket: "example-bucket",
|
||||
measurement: "example-measurement"
|
||||
)
|
||||
```
|
||||
|
||||
## List tag values
|
||||
Use the [`v1.tagValues()` function](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)
|
||||
to list **tag values for a given tag in a bucket**.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.tagValues(bucket: "example-bucket", tag: "example-tag")
|
||||
```
|
||||
|
||||
### List tag values in a measurement
|
||||
Use the [`v1.measurementTagValues` function](/v2.0/reference/flux/stdlib/influxdb-v1/measurementtagvalues)
|
||||
to list **tag values for a given tag in a measurement**.
|
||||
_This function returns results from the last 30 days._
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.measurementTagValues(
|
||||
bucket: "example-bucket",
|
||||
tag: "example-tag",
|
||||
measurement: "example-measurement"
|
||||
)
|
||||
```
|
|
@ -10,7 +10,7 @@ menu:
|
|||
v2_0:
|
||||
name: Transform data with math
|
||||
parent: Query with Flux
|
||||
weight: 205
|
||||
weight: 208
|
||||
aliases:
|
||||
- /v2.0/query-data/guides/mathematic-operations/
|
||||
related:
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
title: v1.fieldKeys() function
|
||||
description: The `v1.fieldKeys()` function returns field keys in a bucket.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: v1.fieldKeys
|
||||
parent: InfluxDB v1
|
||||
weight: 301
|
||||
v2.0/tags: [fields]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-field-keys, SHOW FIELD KEYS in InfluxQL
|
||||
---
|
||||
|
||||
The `v1.fieldKeys()` function returns field keys in a bucket.
|
||||
The return value is always a single table with a single column, `_value`.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.fieldKeys(
|
||||
bucket: "example-bucket",
|
||||
predicate: (r) => true,
|
||||
start: -30d
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### bucket
|
||||
The bucket to list field keys from.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### predicate
|
||||
The predicate function that filters field keys.
|
||||
_Defaults to `(r) => true`._
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
### start
|
||||
The oldest time to include in results.
|
||||
_Defaults to `-30d`._
|
||||
|
||||
Relative start times are defined using negative durations.
|
||||
Negative durations are relative to now.
|
||||
Absolute start times are defined using timestamps.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
## Examples
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.fieldKeys(bucket: "my-bucket")
|
||||
```
|
||||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
fieldKeys = (bucket, predicate=(r) => true, start=-30d) =>
|
||||
tagValues(bucket: bucket, tag: "_field", predicate: predicate, start: start)
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
[v1.tagValues](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues/)_
|
|
@ -36,6 +36,8 @@ from(bucket:"example-bucket")
|
|||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
fieldsAsCols = (tables=<-) =>
|
||||
tables
|
||||
|> pivot(
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
title: v1.measurementFieldKeys() function
|
||||
description: The `v1.measurementFieldKeys()` function returns a list of fields in a measurement.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: v1.measurementFieldKeys
|
||||
parent: InfluxDB v1
|
||||
weight: 301
|
||||
v2.0/tags: [fields]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-field-keys, SHOW FIELD KEYS in InfluxQL
|
||||
---
|
||||
|
||||
The `v1.measurementFieldKeys()` function returns a list of fields in a measurement.
|
||||
The return value is always a single table with a single column, `_value`.
|
||||
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.measurementFieldKeys(
|
||||
bucket: "example-bucket",
|
||||
measurement: "example-measurement",
|
||||
start: -30d
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### bucket
|
||||
The bucket to list field keys from.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### measurement
|
||||
The measurement to list field keys from.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### start
|
||||
The oldest time to include in results.
|
||||
_Defaults to `-30d`._
|
||||
|
||||
Relative start times are defined using negative durations.
|
||||
Negative durations are relative to now.
|
||||
Absolute start times are defined using timestamps.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
## Examples
|
||||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.measurementFieldKeys(
|
||||
bucket: "telegraf",
|
||||
measurement: "cpu",
|
||||
)
|
||||
```
|
||||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
measurementFieldKeys = (bucket, measurement, start=-30d) =>
|
||||
fieldKeys(bucket: bucket, predicate: (r) => r._measurement == measurement, start: start)
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
[v1.fieldKeys](/v2.0/reference/flux/stdlib/influxdb-v1/fieldkeys/)_
|
|
@ -10,6 +10,7 @@ menu:
|
|||
weight: 301
|
||||
v2.0/tags: [measurements]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-measurements, SHOW MEASUREMENTS in InfluxQL
|
||||
---
|
||||
|
||||
|
@ -31,9 +32,11 @@ _**Data type:** String_
|
|||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
measurements = (bucket) =>
|
||||
tagValues(bucket: bucket, tag: "_measurement")
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
[tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_
|
||||
[v1.tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_
|
||||
|
|
|
@ -10,6 +10,7 @@ menu:
|
|||
weight: 301
|
||||
v2.0/tags: [tags]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-keys, SHOW TAG KEYS in InfluxQL
|
||||
---
|
||||
|
||||
|
@ -39,11 +40,14 @@ _**Data type:** String_
|
|||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
measurementTagKeys = (bucket, measurement) =>
|
||||
tagKeys(
|
||||
bucket: bucket,
|
||||
predicate: (r) => r._measurement == measurement)
|
||||
predicate: (r) => r._measurement == measurement
|
||||
)
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
[tagKeys()](/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys)_
|
||||
[v1.tagKeys()](/v2.0/reference/flux/stdlib/influxdb-v1/tagkeys)_
|
||||
|
|
|
@ -10,6 +10,7 @@ menu:
|
|||
weight: 301
|
||||
v2.0/tags: [tags]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-values, SHOW TAG VALUES in InfluxQL
|
||||
---
|
||||
|
||||
|
@ -48,6 +49,8 @@ _**Data type:** String_
|
|||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
measurementTagValues = (bucket, measurement, tag) =>
|
||||
tagValues(
|
||||
bucket: bucket,
|
||||
|
@ -57,4 +60,4 @@ measurementTagValues = (bucket, measurement, tag) =>
|
|||
```
|
||||
|
||||
_**Used functions:**
|
||||
[tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_
|
||||
[v1.tagValues()](/v2.0/reference/flux/stdlib/influxdb-v1/tagvalues)_
|
||||
|
|
|
@ -10,6 +10,7 @@ menu:
|
|||
weight: 301
|
||||
v2.0/tags: [tags]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-keys, SHOW TAG KEYS in InfluxQL
|
||||
---
|
||||
|
||||
|
@ -40,7 +41,7 @@ _Defaults to `(r) => true`._
|
|||
_**Data type:** Function_
|
||||
|
||||
### start
|
||||
Specifies the oldest time to be included in the results.
|
||||
The oldest time to include in results.
|
||||
_Defaults to `-30d`._
|
||||
|
||||
Relative start times are defined using negative durations.
|
||||
|
@ -59,6 +60,8 @@ v1.tagKeys(bucket: "my-bucket")
|
|||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
tagKeys = (bucket, predicate=(r) => true, start=-30d) =>
|
||||
from(bucket: bucket)
|
||||
|> range(start: start)
|
||||
|
|
|
@ -10,6 +10,7 @@ menu:
|
|||
weight: 301
|
||||
v2.0/tags: [tags]
|
||||
related:
|
||||
- /v2.0/query-data/flux/explore-schema/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/schema_exploration#show-tag-values, SHOW TAG VALUES in InfluxQL
|
||||
---
|
||||
|
||||
|
@ -46,7 +47,7 @@ _Defaults to `(r) => true`._
|
|||
_**Data type:** Function_
|
||||
|
||||
### start
|
||||
Specifies the oldest time to be included in the results.
|
||||
The oldest time to include in results.
|
||||
_Defaults to `-30d`._
|
||||
|
||||
Relative start times are defined using negative durations.
|
||||
|
@ -59,7 +60,7 @@ _**Data type:** Duration_
|
|||
```js
|
||||
import "influxdata/influxdb/v1"
|
||||
|
||||
v1.tagKeys(
|
||||
v1.tagValues(
|
||||
bucket: "my-bucket",
|
||||
tag: "host",
|
||||
)
|
||||
|
@ -67,6 +68,8 @@ v1.tagKeys(
|
|||
|
||||
## Function definition
|
||||
```js
|
||||
package v1
|
||||
|
||||
tagValues = (bucket, tag, predicate=(r) => true, start=-30d) =>
|
||||
from(bucket: bucket)
|
||||
|> range(start: start)
|
||||
|
|
Loading…
Reference in New Issue