Documentation

generate.from() function

Flux 0.17.0+

generate.from generates data using provided parameter values.

import "generate"

generate.from(
  count: 5,
  fn: (n) => n,
  start: 2021-01-01T00:00:00Z,
  stop: 2021-01-02T00:00:00Z
)

Parameters

count

(Required) Number of rows to generate.

fn

(Required) Function used to generate values. The function takes an n parameter that represents the row index, operates on n, and then returns an integer value. Rows use zero-based indexing.

start

(Required) Beginning of the time range to generate values in.

stop

(Required) End of the time range to generate values in.

Examples

Generate sample data

import "generate"

generate.from(
  count: 6,
  fn: (n) => (n + 1) * (n + 2),
  start: 2021-01-01T00:00:00Z,
  stop: 2021-01-02T00:00:00Z,
)
Output data
_time_value
2021-01-01T00:00:00Z2
2021-01-01T04:00:00Z6
2021-01-01T08:00:00Z12
2021-01-01T12:00:00Z20
2021-01-01T16:00:00Z30
2021-01-01T20:00:00Z42

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.