Explore your data schema with Flux
Flux provides functions that let you explore the structure and schema of your data stored in InfluxDB.
Functions in the schema
package are not supported in the Flux REPL.
List buckets
Use buckets() to list buckets in your organization.
buckets()
View example buckets()
output
buckets()
returns a single table with the following columns:
- organizationID: Organization ID
- name: Bucket name
- id: Bucket ID
- retentionPolicy: Retention policy associated with the bucket
- retentionPeriod: Retention period in nanoseconds
organizationID | name | id | retentionPolicy | retentionPeriod |
---|---|---|---|---|
XooX0x0 | _monitoring | XooX0x1 | 604800000000000 | |
XooX0x0 | _tasks | XooX0x2 | 259200000000000 | |
XooX0x0 | example-bucket-1 | XooX0x3 | 0 | |
XooX0x0 | example-bucket-2 | XooX0x4 | 0 | |
XooX0x0 | example-bucket-3 | XooX0x5 | 172800000000000 |
List measurements
Use schema.measurements() to list measurements in a bucket. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.measurements(bucket: "example-bucket")
View example schema.measurements()
output
schema.measurements()
returns a single table with a _value
column. Each row contains the name of a measurement.
_value |
---|
m1 |
m2 |
m3 |
m4 |
m5 |
List field keys
Use schema.fieldKeys to list field keys in a bucket. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.fieldKeys(bucket: "example-bucket")
View example schema.fieldKeys()
output
schema.fieldKeys()
returns a single table with a _value
column. Each row contains a unique field key from the specified bucket.
_value |
---|
field1 |
field2 |
field3 |
field4 |
field5 |
List fields in a measurement
Use schema.measurementFieldKeys to list field keys in a measurement. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.measurementFieldKeys(
bucket: "example-bucket",
measurement: "example-measurement",
)
View example schema.measurementFieldKeys()
output
schema.measurementFieldKeys()
returns a single table with a _value
column. Each row contains the name of a unique field key in the specified bucket and measurement.
_value |
---|
field1 |
field2 |
field3 |
field4 |
field5 |
List tag keys
Use schema.tagKeys() to list tag keys in a bucket. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.tagKeys(bucket: "example-bucket")
View example schema.tagKeys()
output
schema.tagKeys()
returns a single table with a _value
column. Each row contains the a unique tag key from the specified bucket.
_value |
---|
tag1 |
tag2 |
tag3 |
tag4 |
tag5 |
List tag keys in a measurement
Use schema.measurementTagKeys to list tag keys in a measurement. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.measurementTagKeys(
bucket: "example-bucket",
measurement: "example-measurement",
)
View example schema.measurementTagKeys()
output
schema.measurementTagKeys()
returns a single table with a _value
column. Each row contains a unique tag key from the specified bucket and measurement.
_value |
---|
tag1 |
tag2 |
tag3 |
tag4 |
tag5 |
List tag values
Use schema.tagValues() to list tag values for a given tag in a bucket. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.tagValues(bucket: "example-bucket", tag: "example-tag")
View example schema.tagValues()
output
schema.tagValues()
returns a single table with a _value
column. Each row contains a unique tag value from the specified bucket and tag key.
_value |
---|
tagValue1 |
tagValue2 |
tagValue3 |
tagValue4 |
tagValue5 |
List tag values in a measurement
Use schema.measurementTagValues to list tag values for a given tag in a measurement. By default, this function returns results from the last 30 days.
import "influxdata/influxdb/schema"
schema.measurementTagValues(
bucket: "example-bucket",
tag: "example-tag",
measurement: "example-measurement",
)
View example schema.measurementTagValues()
output
schema.measurementTagValues()
returns a single table with a _value
column. Each row contains a unique tag value from the specified bucket, measurement, and tag key.
_value |
---|
tagValue1 |
tagValue2 |
tagValue3 |
tagValue4 |
tagValue5 |