From 77e4f50b924805e29a5b546006a937ee1086d457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=A3=8F?= Date: Mon, 4 Nov 2024 11:45:48 +0800 Subject: [PATCH 1/2] fix alarm send fail --- core/monitor/LogtailAlarm.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/monitor/LogtailAlarm.cpp b/core/monitor/LogtailAlarm.cpp index bd333a7635..e6f49e8ddf 100644 --- a/core/monitor/LogtailAlarm.cpp +++ b/core/monitor/LogtailAlarm.cpp @@ -194,7 +194,15 @@ void LogtailAlarm::SendAllRegionAlarm() { // check sender queue status, if invalid jump this region QueueKey alarmPrjLogstoreKey = QueueKeyManager::GetInstance()->GetKey( - "-flusher_sls-" + GetProfileSender()->GetProfileProjectName(region) + "#logtail_alarm"); + GetProfileSender()->GetProfileProjectName(region) + "-" + "logtail_alarm"); + if (SenderQueueManager::GetInstance()->GetQueue(alarmPrjLogstoreKey) == nullptr) { + PipelineContext ctx; + SenderQueueManager::GetInstance()->CreateQueue( + alarmPrjLogstoreKey, + "", + ctx, + std::unordered_map>()); + } if (!SenderQueueManager::GetInstance()->IsValidToPush(alarmPrjLogstoreKey)) { // jump this region ++sendRegionIndex; From 5a5285e91b0d15f5417236ccce9549650cc27022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=A3=8F?= Date: Mon, 4 Nov 2024 16:43:56 +0800 Subject: [PATCH 2/2] fix alarm send fail --- core/monitor/LogtailAlarm.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/monitor/LogtailAlarm.cpp b/core/monitor/LogtailAlarm.cpp index e6f49e8ddf..0abf2a3ebd 100644 --- a/core/monitor/LogtailAlarm.cpp +++ b/core/monitor/LogtailAlarm.cpp @@ -16,12 +16,12 @@ #include "LogFileProfiler.h" #include "app_config/AppConfig.h" -#include "constants/Constants.h" #include "common/LogtailCommonFlags.h" #include "common/StringTools.h" #include "common/Thread.h" #include "common/TimeUtil.h" #include "common/version.h" +#include "constants/Constants.h" #include "pipeline/queue/QueueKeyManager.h" #include "pipeline/queue/SenderQueueManager.h" #include "protobuf/sls/sls_logs.pb.h" @@ -36,6 +36,8 @@ using namespace sls_logs; namespace logtail { +const string ALARM_SLS_LOGSTORE_NAME = "logtail_alarm"; + LogtailAlarm::LogtailAlarm() { mMessageType.resize(ALL_LOGTAIL_ALARM_NUM); mMessageType[USER_CONFIG_ALARM] = "USER_CONFIG_ALARM"; @@ -193,15 +195,18 @@ void LogtailAlarm::SendAllRegionAlarm() { } // check sender queue status, if invalid jump this region - QueueKey alarmPrjLogstoreKey = QueueKeyManager::GetInstance()->GetKey( - GetProfileSender()->GetProfileProjectName(region) + "-" + "logtail_alarm"); + string project = GetProfileSender()->GetProfileProjectName(region); + QueueKey alarmPrjLogstoreKey + = QueueKeyManager::GetInstance()->GetKey("-flusher_sls-" + project + "#" + ALARM_SLS_LOGSTORE_NAME); if (SenderQueueManager::GetInstance()->GetQueue(alarmPrjLogstoreKey) == nullptr) { PipelineContext ctx; SenderQueueManager::GetInstance()->CreateQueue( alarmPrjLogstoreKey, - "", + "self_monitor", ctx, - std::unordered_map>()); + {{"region", FlusherSLS::GetRegionConcurrencyLimiter(region)}, + {"project", FlusherSLS::GetProjectConcurrencyLimiter(project)}, + {"logstore", FlusherSLS::GetLogstoreConcurrencyLimiter(project, ALARM_SLS_LOGSTORE_NAME)}}); } if (!SenderQueueManager::GetInstance()->IsValidToPush(alarmPrjLogstoreKey)) { // jump this region @@ -213,7 +218,7 @@ void LogtailAlarm::SendAllRegionAlarm() { // LOG_DEBUG(sLogger, ("4Send Alarm", region)("region", sendRegionIndex)("alarm index", // mMessageType[sendAlarmTypeIndex])); logGroup.set_source(LogFileProfiler::mIpAddr); - logGroup.set_category("logtail_alarm"); + logGroup.set_category(ALARM_SLS_LOGSTORE_NAME); auto now = GetCurrentLogtailTime(); for (map::iterator mapIter = alarmMap.begin(); mapIter != alarmMap.end(); ++mapIter) {