log_time
and log_level
from logs, a regular expression function is more suitable. {“Log content”: "2021-12-02 14:33:35.022 [1] INFO org.apache.Load - Response:status: 200, resp msg: OK, resp content: { \\"TxnId\\": 58322, \\"Label\\": \\"flink_connector_20211202_1de749d8c80015a8\\", \\"Status\\": \\"Success\\", \\"Message\\": \\"OK\\", \\"TotalRows\\": 1, \\"LoadedRows\\": 1, \\"FilteredRows\\": 0, \\"CommitAndPublishTimeMs\\": 16}"}
"resonsebody": {"method": "GET","user": "Tom"}
str_count(Value, sub="", start=0, end=-1)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
sub | Substring whose number of occurrences you want to count | string | Yes | - | - |
start | Start position to search | number | No | 0 | - |
end | End position to search | number | No | -1 | - |
{"data": "warn,error,error"}
fields_set("result", str_count(v("data"), sub="err"))
{"result":"2","data":"warn,error,error"}
str_len(Value)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
{"data": "warn,error,error"}
fields_set("result", str_len(v("data")))
{"result":"16","data":"warn,error,error"}
str_uppercase(Value)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
{"data": "warn,error,error"}
fields_set("result", str_uppercase(v("data")))
{"result":"WARN,ERROR,ERROR","data":"warn,error,error"}
str_lowercase(Value)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
fields_set("result", str_lowercase(v("data")))
{"data": "WARN,ERROR,ERROR"}
{"result":"warn,error,error","data":"WARN,ERROR,ERROR"}
str_join(Concatenation string 1, Value 1, Value 2, ...)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
join | Value of string type | string | Yes | - | - |
Value parameter, list of variable parameters | Value of string type | string | Yes | - | - |
{"data": "WARN,ERROR,ERROR"}
fields_set("result", str_join(",", v("data"), "INFO"))
{"result":"WARN,ERROR,ERROR,INFO","data":"WARN,ERROR,ERROR"}
str_replace(Value, old="", new="", count=0)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
old | String to the replaced | string | Yes | - | - |
new | Target string after replacement | string | Yes | - | - |
count | Maximum replacement count. The default value is 0 , replacing all matched content. | number | No | 0 | - |
data
field with "ERROR".{"data": "WARN,ERROR,ERROR"}
fields_set("result", str_replace( v("data"), old="WARN", new="ERROR"))
result
.
Processing result:{"result":"ERROR,ERROR,ERROR","data":"WARN,ERROR,ERROR"}
str_format(Formatted string, Value 1, Value 2, ...)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
format | Target format, using "{}" as placeholders, such as "The disk "{1}" contains {0} file(s).". The numbers in "{}" correspond to the sequence numbers of the parameter values, and the numbers start from 0. For usage details, see MessageFormat.format. | string | Yes | - | - |
Value parameter, list of variable parameters | Value of string type | string | Yes | - | - |
{"status": 200, "message":"OK"}
fields_set("result", str_format("status:{0}, message:{1}", v("status"), v("message")))
{"result":"status:200, message:OK","message":"OK","status":"200"}
str_strip(Value, chars="\\t\\r\\n")
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
chars | String to delete | string | No | \\t\\r\\n | - |
{"data": " abc "}
fields_set("result", str_strip(v("data"), chars=" "))
{"result":"abc","data":" abc "}
{"data": " **abc** "}
fields_set("result", str_strip(v("data"), chars=" *"))
{"result":"abc","data":" **abc** "}
str_strip(Value, chars="\\t\\r\\n")
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
chars | String to delete | string | No | \\t\\r\\n | - |
{"data": " abc "}
fields_set("result", str_lstrip(v("data"), chars=" "))
{"result":"abc ","data":" abc "}
str_strip(Value, chars="\\t\\r\\n")
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
chars | String to delete | string | No | \\t\\r\\n | - |
{"data": " abc "}
fields_set("result", str_rstrip(v("data"), chars=" "))
{"result":" abc","data":" abc "}
str_find(Value, sub="", start=0, end=-1)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
sub | Substring whose number of occurrences you want to count | string | Yes | - | - |
start | Start position to search | number | No | 0 | - |
end | End position to search | number | No | -1 | - |
{"data": "warn,error,error"}
fields_set("result", str_find(v("data"), sub="err"))
{"result":"5","data":"warn,error,error"}
str_start_with(Value, sub="", start=0, end=-1)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
sub | Prefix string or character | string | Yes | - | - |
start | Start position to search | number | No | 0 | - |
end | End position to search | number | No | -1 | - |
{"data": "something"}
fields_set("result", str_start_with(v("data"), sub="some"))
{"result":"true","data":"something"}
{"data": "something"}
fields_set("result", str_start_with(v("data"), sub="*"))
{"result":"false","data":"something"}
str_end_with(Value, sub="", start=0, end=-1)
Parameter | Description | Parameter Type | Required | Default Value | Value Range |
data | Value of string type | string | Yes | - | - |
sub | Prefix string or character | string | Yes | - | - |
start | Start position to search | number | No | 0 | - |
end | End position to search | number | No | -1 | - |
{"data": "endwith something"}
fields_set("result", str_end_with(v("data"), sub="ing"))
{"result":"true","data":"endwith something"}
Was this page helpful?