compose(Function 1,Function 2, ...)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
Variable parameter, function | The parameter must be a function whose return value type is LOG. | string | At least one function parameter | - | - |
enrich
function first and then the fields_set
function
Raw log:{"status": "500"}
// 1. `enrich` function: use the data in `dict` to enrich the raw log, where `status` is `500`, and generate a field (field `message` with value `Failed`) after the enrichment.//2. `fields_Set` function: add a field `new` and assign value `1` to it.compose(enrich_dict("{\\"200\\":\\"SUCCESS\\",\\"500\\":\\"FAILED\\"}", "status", output="message"), fields_set("new", 1))
// The final log contains 3 fields:{"new":"1","message":"FAILED","status":"500"}
{"status": "500"}
compose(fields_set("new", 1))
{"new":"1","status":"500"}
{"condition1": 0,"condition2": 1, "status": "500"}
t_if_else(v("condition2"), compose(fields_set("new", 1),log_output("target")), log_output("target2"))
target
output: {"new":"1","condition1":"0","condition2":"1","status":"500"}
t_if(Condition 1, Function 1)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
condition | Function expression whose return value is of bool type | bool | Yes | - | - |
function | Function expression whose return value is of LOG type | string | Yes | - | - |
{"condition": 1, "status": "500"}
t_if(True, fields_set("new", 1))
{"new":"1","condition":"1","status":"500"}
// If the value of `condition` is `1` (true), add a field `new` and assign value `1` to it.{"condition": 1, "status": "500"}
t_if(v("condition"), fields_set("new", 1))
{"new":"1","condition":"1","status":"500"}
t_if_not(Condition 1, Function 1)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
condition | Function expression whose return value is of bool type | bool | Yes | - | - |
function | Function expression whose return value is of LOG type | string | Yes | - | - |
{"condition": 0, "status": "500"}
t_if_not(v("condition"), fields_set("new", 1))
{"new":"1","condition":"0","status":"500"}
t_if_else("Condition 1", Function 1, Function 2)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
condition | Function expression whose return value is of bool type | bool | Yes | - | - |
function | Function expression whose return value is of LOG type | string | Yes | - | - |
function | Function expression whose return value is of LOG type | string | Yes | - | - |
{"condition": 1, "status": "500"}
t_if_else(v("condition"), fields_set("new", 1), fields_set("new", 2))
{"new":"1","condition":"1","status":"500"}
t_switch("Condition 1", Function 1, "Condition 2", Function 2, ...)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
Variable parameter, which is a list of condition-function expression pairs | - | - | - | - |
{"condition1": 0,"condition2": 1, "status": "500"}
// If `condition1` is `1` (true), add a field `new` and assign value `1` to it. Here, `False` is returned for `condition1`, and therefore the `new` field (value: `1`) is not added; `True` is returned for `condition2`, and therefore the `new` field (value: `2`) is added.t_switch(v("condition1"), fields_set("new", 1), v("condition2"), fields_set("new", 2))
{"new":"2","condition1":"0","condition2":"1","status":"500"}
Was this page helpful?