tickscript.join() 函数
tickscript.join()
是一个用户贡献函数,由包作者维护。
tickscript.join()
将两个输入流合并为一个输出流,基于指定列的相等值,并附加一个新的 measurement 名称。
此函数类似于 Kapacitor JoinNode。
函数类型签名
(measurement: A, tables: B, ?on: [string]) => stream[{C with _measurement: A}] where B: Record, C: Record
有关更多信息,请参阅 函数类型签名。
参数
tables
(必需)要连接的两个流的映射。
on
要连接的列的列表。默认为 ["_time"]
。
measurement
(必需)在结果中使用的 Measurement 名称。
示例
连接两个数据流
import "array"
import "contrib/bonitoo-io/tickscript"
metrics =
array.from(
rows: [
{_time: 2021-01-01T00:00:00Z, host: "host1", _value: 1.2},
{_time: 2021-01-01T01:00:00Z, host: "host1", _value: 0.8},
{_time: 2021-01-01T02:00:00Z, host: "host1", _value: 3.2},
{_time: 2021-01-01T00:00:00Z, host: "host2", _value: 8.4},
{_time: 2021-01-01T01:00:00Z, host: "host2", _value: 7.3},
{_time: 2021-01-01T02:00:00Z, host: "host2", _value: 7.9},
],
)
|> group(columns: ["host"])
states =
array.from(
rows: [
{_time: 2021-01-01T00:00:00Z, host: "host1", _value: "dead"},
{_time: 2021-01-01T01:00:00Z, host: "host1", _value: "dead"},
{_time: 2021-01-01T02:00:00Z, host: "host1", _value: "alive"},
{_time: 2021-01-01T00:00:00Z, host: "host2", _value: "alive"},
{_time: 2021-01-01T01:00:00Z, host: "host2", _value: "alive"},
{_time: 2021-01-01T02:00:00Z, host: "host2", _value: "alive"},
],
)
|> group(columns: ["host"])
tickscript.join(
tables: {metric: metrics, state: states},
on: ["_time", "host"],
measurement: "example-m",
)
此页面是否对您有帮助?
感谢您的反馈!