from() function

The from() function retrieves data from an InfluxDB data source. It returns a stream of tables from the specified bucket. Each unique series is contained within its own table. Each record in the table represents a single point in the series.

*Function type: Input
**
Output data type:* Record

  1. from(
  2. bucket: "example-bucket",
  3. host: "https://example.com",
  4. org: "example-org",
  5. token: "MySuP3rSecr3Tt0k3n"
  6. )
  7. // OR
  8. from(
  9. bucketID: "0261d8287f4d6000",
  10. host: "https://example.com",
  11. orgID: "example-org",
  12. token: "MySuP3rSecr3Tt0k3n"
  13. )

Parameters

host, org or orgID, and token parameters are only required when querying data from a different organization or a remote InfluxDB instance.

bucket

Name of the bucket to query.

*Data type: String*

bucketID

String-encoded bucket ID to query.

*Data type: String*

host

URL of the InfluxDB instance to query. See InfluxDB URLs.

*Data type: String*

org

Organization name.

*Data type: String*

orgID

String-encoded organization ID to query.

*Data type: String*

token

InfluxDB authentication token.

*Data type: String*

Examples

Query using the bucket name
  1. from(bucket: "example-bucket")
Query using the bucket ID
  1. from(bucketID: "0261d8287f4d6000")
Query a remote InfluxDB Cloud instance
  1. import "influxdata/influxdb/secrets"
  2. token = secrets.get(key: "INFLUXDB_CLOUD_TOKEN")
  3. from(
  4. bucket: "example-bucket",
  5. host: "https://cloud2.influxdata.com",
  6. org: "example-org",
  7. token: token
  8. )

Related articles