tickscript.join() function
The tickscript.join()
function is a user-contributed function maintained by
the package author and can
be updated or removed at any time.
The tickscript.join()
function merges two input streams into a single output
stream based on specified columns with equal values and appends a new measurement name.
This function is comparable to the Kapacitor JoinNode.
import "contrib/bonitoo-io/tickscript"
tickscript.join(
tables: {t1: example1, t2: example2},
on: ["_time"],
measurement: "example-measurement",
)
Parameters
tables
(Required) Map of two streams to join.
on
List of columns to join on.
Default is ["_time"]
.
measurement
(Required) Measurement name to use in results.
Examples
Join two streams of data
Input data
metrics
_time | host | _value |
---|---|---|
2021-01-01T00:00:00Z | host1 | 1.2 |
2021-01-01T01:00:00Z | host1 | 0.8 |
2021-01-01T02:00:00Z | host1 | 3.2 |
_time | host | _value |
---|---|---|
2021-01-01T00:00:00Z | host2 | 8.4 |
2021-01-01T01:00:00Z | host2 | 7.3 |
2021-01-01T02:00:00Z | host2 | 7.9 |
states
_time | host | _value |
---|---|---|
2021-01-01T00:00:00Z | host1 | dead |
2021-01-01T01:00:00Z | host1 | dead |
2021-01-01T02:00:00Z | host1 | alive |
_time | host | _value |
---|---|---|
2021-01-01T00:00:00Z | host2 | alive |
2021-01-01T01:00:00Z | host2 | alive |
2021-01-01T02:00:00Z | host2 | alive |
Query
import "contrib/bonitoo-io/tickscript"
metrics = //...
states = //...
tickscript.join(
tables: {metric: metrics, state: states},
on: ["_time", "host"],
measurement: "example-m",
)
Output data
_measurement | host | _time | _value_metric | _value_state |
---|---|---|---|---|
example-m | host1 | 2021-01-01T00:00:00Z | 1.2 | dead |
example-m | host1 | 2021-01-01T01:00:00Z | 0.8 | dead |
example-m | host1 | 2021-01-01T02:00:00Z | 3.2 | alive |
_measurement | host | _time | _value_metric | _value_state |
---|---|---|---|---|
example-m | host2 | 2021-01-01T00:00:00Z | 8.4 | alive |
example-m | host2 | 2021-01-01T01:00:00Z | 7.3 | alive |
example-m | host2 | 2021-01-01T02:00:00Z | 7.9 | alive |
Package author and maintainer
Github: @bonitoo-io, @alespour
InfluxDB Slack: @Ales Pour
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.