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.

  1. 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
organizationIDnameidretentionPolicyretentionPeriod
XooX0x0_monitoringXooX0x1604800000000000
XooX0x0_tasksXooX0x2259200000000000
XooX0x0example-bucket-1XooX0x30
XooX0x0example-bucket-2XooX0x40
XooX0x0example-bucket-3XooX0x5172800000000000

List measurements

Use schema.measurements() to list measurements in a bucket. By default, this function returns results from the last 30 days.

  1. import "influxdata/influxdb/schema"
  2. 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.

  1. import "influxdata/influxdb/schema"
  2. 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.

  1. import "influxdata/influxdb/schema"
  2. schema.measurementFieldKeys(
  3. bucket: "example-bucket",
  4. measurement: "example-measurement",
  5. )

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.

  1. import "influxdata/influxdb/schema"
  2. 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.

  1. import "influxdata/influxdb/schema"
  2. schema.measurementTagKeys(
  3. bucket: "example-bucket",
  4. measurement: "example-measurement",
  5. )

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.

  1. import "influxdata/influxdb/schema"
  2. 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.

  1. import "influxdata/influxdb/schema"
  2. schema.measurementTagValues(
  3. bucket: "example-bucket",
  4. tag: "example-tag",
  5. measurement: "example-measurement",
  6. )

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

schema