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:00Z 2
2021-01-01T04:00:00Z 6
2021-01-01T08:00:00Z 12
2021-01-01T12:00:00Z 20
2021-01-01T16:00:00Z 30
2021-01-01T20:00:00Z 42

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.