diff --git a/core/constants/Constants.cpp b/core/constants/Constants.cpp index 9fcc30d73b..e7536b57f8 100644 --- a/core/constants/Constants.cpp +++ b/core/constants/Constants.cpp @@ -39,6 +39,7 @@ const char* SLS_EMPTY_STR_FOR_INDEX = "\01"; // profile project const std::string PROFILE_PROJECT = "profile_project"; const std::string PROFILE_PROJECT_REGION = "profile_project_region"; +const std::string PROFILE_LOGSTORE = "profile_logstore"; // global config const std::string GLOBAL_CONFIG_NODE = "config"; diff --git a/core/constants/Constants.h b/core/constants/Constants.h index 95bed2bec9..48ddacaab5 100644 --- a/core/constants/Constants.h +++ b/core/constants/Constants.h @@ -40,6 +40,7 @@ extern const char* SLS_EMPTY_STR_FOR_INDEX; // profile project extern const std::string PROFILE_PROJECT; extern const std::string PROFILE_PROJECT_REGION; +extern const std::string PROFILE_LOGSTORE; // global config extern const std::string GLOBAL_CONFIG_NODE; diff --git a/core/monitor/MetricManager.cpp b/core/monitor/MetricManager.cpp index 21aa50c68a..aae567c11f 100644 --- a/core/monitor/MetricManager.cpp +++ b/core/monitor/MetricManager.cpp @@ -28,9 +28,6 @@ using namespace std; namespace logtail { -const string METRIC_KEY_CATEGORY = "category"; -const string METRIC_KEY_LABEL = "label"; -const string METRIC_TOPIC_TYPE = "loongcollector_metric"; const string METRIC_EXPORT_TYPE_GO = "direct"; const string METRIC_EXPORT_TYPE_CPP = "cpp_provided"; diff --git a/core/monitor/MetricManager.h b/core/monitor/MetricManager.h index 3f28b9b477..ad5b743a8d 100644 --- a/core/monitor/MetricManager.h +++ b/core/monitor/MetricManager.h @@ -30,8 +30,6 @@ namespace logtail { -extern const std::string METRIC_TOPIC_TYPE; - class WriteMetrics { private: WriteMetrics() = default; diff --git a/core/monitor/SelfMonitorServer.cpp b/core/monitor/SelfMonitorServer.cpp index 690c0beca5..d4a75e141a 100644 --- a/core/monitor/SelfMonitorServer.cpp +++ b/core/monitor/SelfMonitorServer.cpp @@ -100,7 +100,6 @@ void SelfMonitorServer::SendMetrics() { PipelineEventGroup pipelineEventGroup(std::make_shared()); pipelineEventGroup.SetTagNoCopy(LOG_RESERVED_KEY_SOURCE, LoongCollectorMonitor::mIpAddr); - pipelineEventGroup.SetTagNoCopy(LOG_RESERVED_KEY_TOPIC, METRIC_TOPIC_TYPE); ReadAsPipelineEventGroup(pipelineEventGroup); shared_ptr pipeline diff --git a/core/pipeline/plugin/PluginRegistry.cpp b/core/pipeline/plugin/PluginRegistry.cpp index bf0d7acbe6..469b2c06b1 100644 --- a/core/pipeline/plugin/PluginRegistry.cpp +++ b/core/pipeline/plugin/PluginRegistry.cpp @@ -28,6 +28,9 @@ #include "plugin/flusher/blackhole/FlusherBlackHole.h" #include "plugin/flusher/file/FlusherFile.h" #include "plugin/flusher/sls/FlusherSLS.h" +#ifdef __ENTERPRISE__ +#include "plugin/flusher/sls/EnterpriseFlusherSLSMonitor.h" +#endif #include "plugin/input/InputContainerStdio.h" #include "plugin/input/InputFile.h" #include "plugin/input/InputPrometheus.h" @@ -160,6 +163,9 @@ void PluginRegistry::LoadStaticPlugins() { RegisterFlusherCreator(new StaticFlusherCreator()); RegisterFlusherCreator(new StaticFlusherCreator()); RegisterFlusherCreator(new StaticFlusherCreator()); +#ifdef __ENTERPRISE__ + RegisterFlusherCreator(new StaticFlusherCreator()); +#endif } void PluginRegistry::LoadDynamicPlugins(const set& plugins) { diff --git a/core/plugin/flusher/sls/FlusherSLS.cpp b/core/plugin/flusher/sls/FlusherSLS.cpp index 3fcdb6fa6b..36779aa44d 100644 --- a/core/plugin/flusher/sls/FlusherSLS.cpp +++ b/core/plugin/flusher/sls/FlusherSLS.cpp @@ -212,6 +212,9 @@ mutex FlusherSLS::sProjectRefCntMapLock; unordered_map FlusherSLS::sProjectRefCntMap; mutex FlusherSLS::sRegionRefCntMapLock; unordered_map FlusherSLS::sRegionRefCntMap; +mutex FlusherSLS::sProjectRegionMapLock; +unordered_map FlusherSLS::sProjectRegionMap; + string FlusherSLS::GetAllProjects() { string result; @@ -261,6 +264,21 @@ void FlusherSLS::DecreaseRegionReferenceCnt(const string& region) { } } +std::string FlusherSLS::GetProjectRegion(const std::string& project) { + lock_guard lock(sProjectRefCntMapLock); + return sProjectRegionMap[project]; +} + +void FlusherSLS::SetProjectRegion(const std::string& project, const std::string& region) { + lock_guard lock(sProjectRefCntMapLock); + sProjectRegionMap[project] = region; +} + +void FlusherSLS::RemoveProjectRegion(const std::string& project) { + lock_guard lock(sProjectRefCntMapLock); + sProjectRegionMap.erase(project); +} + mutex FlusherSLS::sRegionStatusLock; unordered_map FlusherSLS::sAllRegionStatus; @@ -542,6 +560,7 @@ bool FlusherSLS::Start() { IncreaseProjectReferenceCnt(mProject); IncreaseRegionReferenceCnt(mRegion); + SetProjectRegion(mProject, mRegion); SLSClientManager::GetInstance()->IncreaseAliuidReferenceCntForRegion(mRegion, mAliuid); return true; } @@ -551,6 +570,7 @@ bool FlusherSLS::Stop(bool isPipelineRemoving) { DecreaseProjectReferenceCnt(mProject); DecreaseRegionReferenceCnt(mRegion); + RemoveProjectRegion(mProject); SLSClientManager::GetInstance()->DecreaseAliuidReferenceCntForRegion(mRegion, mAliuid); return true; } diff --git a/core/plugin/flusher/sls/FlusherSLS.h b/core/plugin/flusher/sls/FlusherSLS.h index c874a71f1e..21336f20ef 100644 --- a/core/plugin/flusher/sls/FlusherSLS.h +++ b/core/plugin/flusher/sls/FlusherSLS.h @@ -49,6 +49,7 @@ class FlusherSLS : public HttpFlusher { static void SetDefaultRegion(const std::string& region); static std::string GetAllProjects(); static bool IsRegionContainingConfig(const std::string& region); + static std::string GetProjectRegion(const std::string& project); // TODO: should be moved to enterprise config provider static bool GetRegionStatus(const std::string& region); @@ -94,6 +95,8 @@ class FlusherSLS : public HttpFlusher { static void DecreaseProjectReferenceCnt(const std::string& project); static void IncreaseRegionReferenceCnt(const std::string& region); static void DecreaseRegionReferenceCnt(const std::string& region); + static void SetProjectRegion(const std::string& project, const std::string& region); + static void RemoveProjectRegion(const std::string& project); static std::mutex sMux; static std::unordered_map> sProjectConcurrencyLimiterMap; @@ -107,6 +110,8 @@ class FlusherSLS : public HttpFlusher { static std::unordered_map sProjectRefCntMap; static std::mutex sRegionRefCntMapLock; static std::unordered_map sRegionRefCntMap; + static std::mutex sProjectRegionMapLock; + static std::unordered_map sProjectRegionMap; // TODO: should be moved to enterprise config provider static std::mutex sRegionStatusLock;