logstash add field alert field

main
ycz008 2024-04-01 15:22:16 +08:00
parent 79a130b3c1
commit b79397287b
2 changed files with 5 additions and 5 deletions

View File

@ -6,12 +6,12 @@ if (($#!=6));then
exit 1
fi
if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 || -z $6 ]];then
echo "one of '%{@timestamp} %{serviceName} %{env} %{level} %{message} %{stack_trace}' is empty"
if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 || -z $6 || -z $7 ]];then
echo "one of '%{@timestamp} %{serviceName} %{env} %{level} %{TID} %{message} %{stack_trace}' is empty"
exit 1
fi
msg="timestamp: $1\nserviceName: $2\nenv: $3\nlevel: $4\nmessage: $5\nstack_trace: $6\n<at user_id=\\\"all\\\"></at>\n"
msg="timestamp: $1\nserviceName: $2\nenv: $3\nlevel: $4\ntraceID: $5\nmessage: $6\nstack_trace: $7\n<at user_id=\\\"all\\\"></at>\n"
#echo -ne $msg
curl -X POST -H "Content-Type: application/json" -d "{\"msg_type\":\"text\",\"content\":{\"text\":\"$msg\"}}" https://open.feishu.cn/open-apis/bot/v2/hook/29dd52e5-70d5-44b0-a443-22ea85382646

View File

@ -105,11 +105,11 @@ data:
# }
if [stack_trace] {
exec {
command => "/usr/local/bin/log-alert.sh '%{@timestamp}' '%{serviceName}' '%{env}' '%{level}' '%{message}' '%{stackFirst}' "
command => "/usr/local/bin/log-alert.sh '%{@timestamp}' '%{serviceName}' '%{env}' '%{level}' '%{TID}' '%{message}' '%{stackFirst}' "
}
} else {
exec {
command => "/usr/local/bin/log-alert.sh '%{@timestamp}' '%{serviceName}' '%{env}' '%{level}' '%{message}' '-' "
command => "/usr/local/bin/log-alert.sh '%{@timestamp}' '%{serviceName}' '%{env}' '%{level}' '%{TID}' '%{message}' '-' "
}
}
}