Skip to content

Commit

Permalink
fix alarm send fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Takuka0311 committed Nov 4, 2024
1 parent 77e4f50 commit 5a5285e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/monitor/LogtailAlarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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";
Expand Down Expand Up @@ -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<std::string, std::shared_ptr<ConcurrencyLimiter>>());
{{"region", FlusherSLS::GetRegionConcurrencyLimiter(region)},
{"project", FlusherSLS::GetProjectConcurrencyLimiter(project)},
{"logstore", FlusherSLS::GetLogstoreConcurrencyLimiter(project, ALARM_SLS_LOGSTORE_NAME)}});
}
if (!SenderQueueManager::GetInstance()->IsValidToPush(alarmPrjLogstoreKey)) {
// jump this region
Expand All @@ -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<string, LogtailAlarmMessage*>::iterator mapIter = alarmMap.begin(); mapIter != alarmMap.end();
++mapIter) {
Expand Down

0 comments on commit 5a5285e

Please sign in to comment.