Documentation

usage.from() function

The usage.from() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The usage.from() function returns usage data from an InfluxDB Cloud organization.

import "experimental/usage"

usage.from(
  start: -30d,
  stop: now(),
  host: "",
  orgID: "",
  token: "",
  raw: false
)

View usage data schema

Parameters

start

(Required) Earliest time to include in results.

Data type: Time | Duration

stop

(Required) Earliest time to include in results.

Data type: Time | Duration

host

InfluxDB Cloud region URL (Required if executed outside of your InfluxDB Cloud organization or region). Default is "".

Data type: String

orgID

InfluxDB Cloud organization ID (Required if executed outside of your InfluxDB Cloud organization or region). Default is "".

Data type: String

token

InfluxDB Cloud authentication token (Required if executed outside of your InfluxDB Cloud organization or region). Default is "".

Data type: String

raw

Return raw, high resolution usage data instead of downsampled usage data. Default is false.

Data type: Boolean

usage.from() can query the following time ranges:

Data resolutionMaximum time range
raw1 hour
downsampled30 days

Examples

Query downsampled usage data for your InfluxDB Cloud organization
import "experimental/usage"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "INFLUX_TOKEN")

usage.from(
  start: -30d,
  stop: now()
)
Query raw usage data for your InfluxDB Cloud organization
import "experimental/usage"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "INFLUX_TOKEN")

usage.from(
  start: -1h,
  stop: now(),
  raw: true
)
Query downsampled usage data for a different InfluxDB Cloud organization
import "experimental/usage"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "INFLUX_TOKEN")

usage.from(
  start: -30d,
  stop: now(),
  host: "https://cloud2.influxdata.com",
  orgID: "x000X0x0xx0X00x0",
  token: token
)

Select your region

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.