From b79397287bf7f5a58e51306b2ce297dece5ef47b Mon Sep 17 00:00:00 2001 From: ycz008 Date: Mon, 1 Apr 2024 15:22:16 +0800 Subject: [PATCH] logstash add field alert field --- build-image/logstash/log-alert.sh | 6 +++--- dev-upgrade/elastic/logstash-alert.yaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build-image/logstash/log-alert.sh b/build-image/logstash/log-alert.sh index 432183c..42eabc9 100755 --- a/build-image/logstash/log-alert.sh +++ b/build-image/logstash/log-alert.sh @@ -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\n" +msg="timestamp: $1\nserviceName: $2\nenv: $3\nlevel: $4\ntraceID: $5\nmessage: $6\nstack_trace: $7\n\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 diff --git a/dev-upgrade/elastic/logstash-alert.yaml b/dev-upgrade/elastic/logstash-alert.yaml index 837036d..7c5f6cb 100644 --- a/dev-upgrade/elastic/logstash-alert.yaml +++ b/dev-upgrade/elastic/logstash-alert.yaml @@ -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}' '-' " } } }