InfluxEx.GenData (influx_ex v0.3.1)
Module for generating series of data, mostly useful for development and test
Link to this section Summary
Types
Define fields and what value(s) a field can contain
Options to use when generating the data
A list of the unique tag sets to use to generate the data points
Define how after back the time window can go in minutes
Functions
Generate data to be written to the InfluxDB
Link to this section Types
field_def()
Define fields and what value(s) a field can contain
random-generated-value
Random generated value
If you want the generation code to generate an integer for you just have to specify the name of the field
InfluxDB.GenData.generate("my.measurement", [:temp, :humidity])
specific-value
Specific value
If you want all the values of a field to be the same you can specify that by passing that value with the field name:
InfluxDB.GenData.generate("my.measurement", [{:temp, 100}, {:humidity, 50}])
with-a-range-of-values
With a range of values
If you want the fields to be in a specific range you can you pass the range along with the field name:
InfluxDB.GenData.generate("my.measurement", [{:temp, -20..130}])
Values within the range are selected randomly.
with-a-group-of-values
With a group of values
If you have a known list of possible values you can pass a that list along with the field name:
InfluxDB.GenData.generate("my.measurement", [{:temp, [1, 5, 10]}])
gen_opt()
@type gen_opt() :: {:tags, tags()} | {:window, window_def()} | {:precision, :second}
Options to use when generating the data
tags()
@type tags() :: [map()]
A list of the unique tag sets to use to generate the data points
window_def()
@type window_def() :: {integer(), :minute}
Define how after back the time window can go in minutes
Link to this section Functions
generate(measurement_name, fields, opts \\ [])
@spec generate(InfluxEx.measurement(), [field_def()], [gen_opt()]) :: [ InfluxEx.Point.t() ]
Generate data to be written to the InfluxDB
By default this will generate enough data points for the last 5 minutes. Currently, only minute time windows are supported.
By default the precision is in seconds and when writing the data using
InfluxEx.write/4
you will to pass the :precision
option as :second
.