Documentation

usage.from() function

Flux 0.114.0+

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.

stop

(Required) Earliest time to include in results.

host

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

orgID

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

token

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

raw

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

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
)

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.