1. FieldJavaScript
- Author: zihjiang
- Version: 0.0.1
1.1.1. Description
用javascript的语法来处理数据, 实现process函数, 返回必须是一个字符串
name | type | required | default value |
---|---|---|---|
target_field | string | yes | |
script | string | yes | |
common-options | string | no | - |
target_field [string]
目标字段名
script [string]
javascript的脚本文件, 主要实现process的函数, 返回了一个字符串
function process(d) {
// 固定返回字符串
// d为所有字段的对象
// 格式为{"key": "value"}
return d;
}
common options [string]
Transform
组件通用参数,详情参照 Transform
配置示例
{
"name": "FieldJavascript",
"plugin_name": "FieldJavascript",
"target_field": "jsfields",
"script": "function process(d) {\n return d;\n}",
"parallelism": "1",
"source_table_name": "FieldOperation_63aa796e_7ffa",
"result_table_name": "FieldJavascript_2233ac0e_5b7e"
}
返回实例
// 源数据
[
{
"randint": "2dda16efea31ea25df7c5fd57dfd242b",
"host": "192.168.1.103",
"id": 1,
"source": "datasource",
"MetricsName": "cpu",
"value": 49,
"_time": 1654956631000
}
]
// 处理后的数据
[
{
"randint": "2dda16efea31ea25df7c5fd57dfd242b",
"host": "192.168.1.103",
"id": 1,
"source": "datasource",
"jsfields": "{\"randint\":\"2dda16efea31ea25df7c5fd57dfd242b\",\"host\":\"192.168.1.103\",\"id\":1,\"source\":\"datasource\",\"MetricsName\":\"cpu\",\"value\":49,\"_time\":1654956631000}",
"MetricsName": "cpu",
"value": 49,
"_time": 1654956631000
}
]