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

17 lines
647 B
Bash
Raw Normal View History

2024-02-26 14:45:35 +08:00
#!/bin/bash
# @timestamp serviceName env level message
if (($#!=6));then
echo "./log-alert.sh %{@timestamp} %{serviceName} %{env} %{level} %{message} %{stack_trace}"
2024-02-26 14:45:35 +08:00
exit 1
fi
if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 || -z $6 ]];then
2024-02-26 14:45:35 +08:00
echo "one of '%{@timestamp} %{serviceName} %{env} %{level} %{message}' is empty"
exit 1
fi
msg="timestamp: $1\nserviceName: $2\nenv: $3\nlevel: $4\nmessage: $5\nstack_trace: $6\n"
2024-02-26 14:45:35 +08:00
#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