Skip to content

Commit

Permalink
Fix alarm send fail (#1853)
Browse files Browse the repository at this point in the history
* fix alarm send fail
  • Loading branch information
Takuka0311 authored Nov 5, 2024
1 parent 16c328a commit eca2371
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 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,8 +195,19 @@ void LogtailAlarm::SendAllRegionAlarm() {
}
// check sender queue status, if invalid jump this region

QueueKey alarmPrjLogstoreKey = QueueKeyManager::GetInstance()->GetKey(
"-flusher_sls-" + 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,
{{"region", FlusherSLS::GetRegionConcurrencyLimiter(region)},
{"project", FlusherSLS::GetProjectConcurrencyLimiter(project)},
{"logstore", FlusherSLS::GetLogstoreConcurrencyLimiter(project, ALARM_SLS_LOGSTORE_NAME)}});
}
if (!SenderQueueManager::GetInstance()->IsValidToPush(alarmPrjLogstoreKey)) {
// jump this region
++sendRegionIndex;
Expand All @@ -205,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 eca2371

Please sign in to comment.