OKR/build-image/logstash/log-alert.sh

18 lines
730 B
Bash
Raw Permalink Normal View History

2024-02-26 14:45:35 +08:00
#!/bin/bash
# @timestamp serviceName env level message
2024-04-01 15:40:49 +08:00
if (($#!=7));then
echo "./log-alert.sh %{@timestamp} %{serviceName} %{env} %{level} %{TID} %{message} %{stack_trace}"
2024-02-26 14:45:35 +08:00
exit 1
fi
2024-04-01 15:22:16 +08:00
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"
2024-02-26 14:45:35 +08:00
exit 1
fi
2024-04-01 15:22:16 +08:00
msg="timestamp: $1\nserviceName: $2\nenv: $3\nlevel: $4\ntraceID: $5\nmessage: $6\nstack_trace: $7\n<at user_id=\\\"all\\\"></at>\n"
2024-02-26 14:45:35 +08:00
#echo -ne $msg
2024-03-07 16:25:29 +08:00
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