tencent cloud

Cloud Log Service

Logstash Statement Reference Table

PDF
Focus Mode
Font Size
Last updated: 2025-12-03 18:30:47
Some Logstash statements correspond to functions in data processing as shown in the table below.
Scenario
Logstash
Data Processing
rename field
mutate
mutate {
rename => {"old_field_name" => "new_field_name"
} }
fields_rename("old_field_name","new_field_name" )
Delete Field
mutate {
remove_field => ["password_hash"]
}
fields_drop("password_hash")
update field value
mutate {
update => {"status_code" => "Not Found"
status_code":"Not Found
fields_set("status_code", "Not Found")
extract key-value pairs - Grok
grok
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:time} %{LOGLEVEL:level} " }}
ext_grok("message",grok="%{TIMESTAMP_ISO8601:time} %{DATA:level}")
extract key-value pairs - Separator
split
mutate {
split => { "message" => "|" }
add_field => {
"time" => "%{[message][0]}"
"level" => "%{[message][1]}"
"taskId" => "%{[message][2]}"
"ProcessName" => "%{[message][3]}"
"ip" => "%{[message][4]}"
}
remove_field => ["message"]
}
ext_sepstr("message","time,loglevel,taskId,ProcessName,ip",sep="\\|")
fields_drop("message")
extract key-value pairs - JSON
json
json {
source => "message"
target => "parsed_data"
}
ext_json("message")
Delete log
drop
if [status] == 404 { //if status=404
Delete log
}
log_drop(delete log
op_eq(v("status"),404)// if the value of status=404
)
Logical judgment
if else
if [log] //if the log field exists
if "Cost" in [message] //when the message field contains "Cost"
t_if(has_field("log")) //if the log field exists
t_if (
str_exist(v(message), "Cost", ignore_upper=True)
if "Cost" in [message] //when the message field contains "Cost"
or , and
if "Cost" in [message] or "cost" in [message]
op_or(
str_exist(v(message), "Cost", ignore_upper=False),
str_exist(v(message), "cost", ignore_upper=False)
)
Distribute logs to multiple sinks (target)
output

if [container] == "scm-pfc" {
elasticsearch {
hosts => ["xx.xx.x.xxx:9200"]
index => "p-k8s"
}

} else {
elasticsearch {
hosts => ["xx.xx.x.xx:9200"]
index => "p-container"
}}
op_str_eq(v("container"),"scm-pfc"),
log_output("p-k8s"), //if branch
log_output("p-container") //else branch
)


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback