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
from(
bucket: "example-bucket",
host: "https://example.com",
org: "example-org",
token: "MySuP3rSecr3Tt0k3n"
)
// OR
from(
bucketID: "0261d8287f4d6000",
host: "https://example.com",
orgID: "example-org",
token: "MySuP3rSecr3Tt0k3n"
)
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
from(bucket: "example-bucket")
Query using the bucket ID
from(bucketID: "0261d8287f4d6000")
Query a remote InfluxDB Cloud instance
import "influxdata/influxdb/secrets"
token = secrets.get(key: "INFLUXDB_CLOUD_TOKEN")
from(
bucket: "example-bucket",
host: "https://cloud2.influxdata.com",
org: "example-org",
token: token
)