Internal InfluxDB
Heisenware incorporates a distinct InfluxDB time series database for each Workspace. This database is utilized to store time series data, enabling its future retrieval, processing, or visualization.
Given that each workspace has its own InfluxDB, various apps within the same Workspace can access data recorded by other apps. For this reason, the name of the InfluxDB contains the name of the Workspace, e.g., acme-influx
.
If you have already set up your own InfluxDB or another time series database, consider using the time series database connector. This will enable you to record and retrieve data to and from your database.
Recording data
To record time series data, you’ll need the recorder function extension. This can be attached to any function output or modifier. Here are the steps to record data:
Click the
+
icon behind an output or modifier.Select
Recorder.
Add a name for the time series data measurement.
During runtime, either in test mode while in the App Builder, or after app deployment, the recording of the value begins. Each trigger of a function with recorder results in a data point. The configuration of the trigger determines the storage interval.
The data is stored as pairs of value and timestamp. The value can be anything, a single number (like a temperature value), an entire object, or even an array of arbitrary type. When data is queried, the associated timestamp appears in the date time string format, a simplified format based on ISO 8601, which is always 24 characters long (YYYY-MM-DDTHH:mm:ss.sssZ
). The timezone is always UTC, as denoted by the suffix Z
.
Retention policy
A retention policy specifies the duration after which data points are overwritten. This means that the oldest data point is always replaced with the most recent one. By default, the retention policy for a new measurement is set to forever
, denoted by the letter F
as part of the recorder.
You can select from various policies: hourly (H
), daily (D
), weekly (W
), monthly (M
), annually (A
), and forever (F
). With the forever
policy, no data points are ever overwritten.
To modify the retention policy of a measurement, follow these steps:
Right-click on the recorder.
Select your preferred retention policy.
Deleting recorder
To delete a recorder:
Right-click on the recorder.
Select
Delete
.
If data has already been logged under a specific measurement, it will be preserved even if the recorder is deleted. If a new recorder is assigned the same measurement name, it will continue to write data to this existing series. This ensures that your data remains intact and accessible, regardless of changes to the recorder setup.
Reading data
Before you can read data from the InfluxDB, ensure that data has been previously recorded. Useful visualization widgets for time series data that is read from the database are the data grid, chart, and sparkline, which are all made for visualizing recorded, historic data.
Read function
To retrieve data from the InfluxDB, you’ll need a read
function. This can be found in the functions panel under the path: Data Connectors
-> Timeseries Database
-> [workspace_name]-influx
.
Input
The read
function requires two inputs:
Bucket: This is the abbreviated name of the bucket to use, as defined in the recorder. It can be
H
,D
,W
,M
,A
, orF
.Measurement: This is the name of the measurement to read, as defined in the recorder.
Output
The read
function outputs an array of objects, where date
and value
are keys within each object. This allows for easy access and manipulation of the retrieved data.
Filters and aggregators
Optional filters and aggregators for the third input:
tail
: Number of latest values to read.start
: Earliest time for results, inclusive. Expects a string. Can be specified using an absolute timestamp, such as2021-01-01T00:00:00Z
, or using a relative timestamp, such as-1h
or-15m
.stop
: Latest time for results, exclusive. Expects a string. Defaults tonow
and can be specified asstart
using absolute or relative timestamps.every
: Aggregation window duration. Expects a string.func
: Aggregation function. Expects a string. Defaults tomean
. Other options aremedian
,min
,max
, orsum.
Recorder shortcut
A shortcut exists to add a pre-configured read
function for a specific measurement. This shortcut can only be used if the original recorder is available in the same app. Click the database icon at the recorder’s right end to add a pre-configured read
function with tail: 100
, which is added directly below the data-recording function.
Query function
The query
function provides raw access to InfluxDB, allowing queries using flux. This is an advanced feature; please consult the InfluxDB documentation for more information.
In the from
statement (e.g., from(bucket: "example-bucket")
), the bucket name corresponds to the retention policy, represented by either H, D, W, M, A, or F.
Last updated