百度智能云

All Product Document

          Log Service

          Process control function

          Flow control

          Introduction

          The logic of flow control is the same across common programming languages and DSL functions, and it is used to control the execution of statements.

          compose function

          Function definition

          A composite operation function, similar to the ability to combine branch code blocks. It can combine multiple operation functions and execute them in sequence, and can be used with branch and output functions. Syntax description

          Syntax description

          compose(function1, function2, ...)

          Parameter description

          Parameter name Parameter description Parameter type Required or not Parameter default Parameter range
          Function 1, 2, ... Parameters must be functions with a return type of LOG String At least one function parameter is required (variable parameters); maximum of 100 parameters - -

          Example

          • Example 1

          Original log:

          {"status": "500"}

          Processing rules:

          compose(e_set("new", 1))

          Processing results:

          {"new": 1, "status": "500"}
          • Example 2

          Original log:

          {"status": "500"}

          Processing rules:

          compose(e_set("new1", "n1"), e_set("new2", "n2"))

          Processing results:

          {"new1": "n1", "new2": "n2", "status": "500"}

          e_if function

          Function definition

          Process logs that meet the condition using the corresponding function; no processing is performed on logs that do not meet the condition.

          Syntax description

          e_if(condition, function)

          Parameter description

          Parameter name Parameter description Parameter type Required or not Parameter default Parameter range
          Condition A function expression that returns a BOOL type Bool Yes - -
          Function Parameters must be functions with a return type of LOG String Yes - -

          Example

          • Example 1

          Original log:

          {"status": "500"}

          Processing rules:

          e_if(true, e_set("new", "n"))

          Processing results:

          {"new": "n", "status":"500"}
          • Example 2

          Original log:

          {"status": "500"}

          Processing rules:

          e_if(false, e_set("new", "n"))

          Processing results:

          {"status": "500"}
          • Example 3

          Original log:

          {"status": "500"}

          Processing rules:

          e_if(v("status") == "500", e_set("new", "n"))

          Processing results:

          {"new": "n", "status":"500"}

          e_if_else function

          Function definition

          Process logs that meet the condition using the corresponding function; no processing is performed on logs that do not meet the condition.

          Syntax description

          e_if_else(condition, function1, function2)

          Parameter description

          Parameter name Parameter description Parameter type Required or not Parameter default Parameter range
          Condition A function expression that returns a BOOL type Bool Yes - -
          Function 1 Parameters must be functions with a return type of LOG String Yes - -
          Function 1 Parameters must be functions with a return type of LOG String Yes - -

          Example

          • Example 1

          Original log:

          {"status": "500"}

          Processing rules:

          e_if_else(true, e_set("new", "n1"), e_set("new", "n2"))

          Processing results:

          {"new": "n1", "status":"500"}
          • Example 2

          Original log:

          {"status": "500"}

          Processing rules:

          e_if_else(false, e_set("new", "n1"), e_set("new", "n2"))

          Processing results:

          {"new": "n2", "status":"500"}

          e_switch function

          Function definition

          Process logs that meet the condition using the corresponding function; no processing is performed on logs that do not meet the condition.

          Syntax description

          e_switch(condition1, function1, condition2, function2, ..., default=None)

          Parameter description

          Parameter name Parameter description Parameter type Required or not Parameter default Parameter range
          Condition 1, 2, ... A function expression that returns a BOOL type Bool At least one parameter is required (variable parameters); maximum of 50 parameters - -
          Function 1, 2, ... Parameters must be functions with a return type of LOG String At least one parameter is required (variable parameters); maximum of 50 parameters - -
          default Parameters must be functions with a return type of LOG, and this operation is executed when no conditions are met. String No - -

          Example

          • Example 1

          Original log:

          {"status": "500"}

          Processing rules:

          e_switch(true, e_set("new", "n"))

          Processing results:

          {"new": "n", "status":"500"}
          • Example 2

          Original log:

          {"status": "500"}

          Processing rules:

          e_switch(false, e_set("new", "n1"), true, e_set("new", "n2"))

          Processing results:

          {"new": "n2", "status":"500"}
          • Example 3

          Original log:

          {"status": "500"}

          Processing rules:

          e_switch(v('status') == '400'), e_set("new", "n1"), default=e_set("new", "n2"))

          Processing results:

          {"new": "n2", "status":"500"}
          Previous
          Field value extraction functions
          Next
          Event operation functions