Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Takuka0311 committed Nov 27, 2024
1 parent 67c9184 commit b3c174d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions core/monitor/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ const string LoongCollectorMonitor::GetInnerSelfMonitorMetricPipeline() {
{
"inputs": [
{
"Type": "input_self_monitor_metric",
"Type": "input_internal_metrics",
"Agent": {
"Enable": false,
"Interval": 1
Expand Down Expand Up @@ -796,8 +796,8 @@ const string LoongCollectorMonitor::GetInnerSelfMonitorMetricPipeline() {
],
"flushers": [
{
"Type": "flusher_local_file",
"FileName": "./log/self_metrics.log"
"Type": "flusher_file",
"FilePath": "./log/self_metrics.log"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions core/pipeline/plugin/PluginRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
#include "app_config/AppConfig.h"
#include "common/Flags.h"
#include "plugin/flusher/blackhole/FlusherBlackHole.h"
#include "plugin/flusher/local_file/FlusherLocalFile.h"
#include "plugin/flusher/file/FlusherFile.h"
#include "plugin/flusher/sls/FlusherSLS.h"
#include "plugin/input/InputContainerStdio.h"
#include "plugin/input/InputFile.h"
#include "plugin/input/InputPrometheus.h"
#if defined(__linux__) && !defined(__ANDROID__)
#include "plugin/input/InputFileSecurity.h"
#include "plugin/input/InputInternalMetrics.h"
#include "plugin/input/InputNetworkObserver.h"
#include "plugin/input/InputNetworkSecurity.h"
#include "plugin/input/InputProcessSecurity.h"
#include "plugin/input/InputSelfMonitorMetric.h"
#endif
#include "logger/Logger.h"
#include "pipeline/plugin/creator/CProcessor.h"
Expand Down Expand Up @@ -127,7 +127,7 @@ bool PluginRegistry::IsValidNativeFlusherPlugin(const string& name) const {
void PluginRegistry::LoadStaticPlugins() {
RegisterInputCreator(new StaticInputCreator<InputFile>());
RegisterInputCreator(new StaticInputCreator<InputPrometheus>());
RegisterInputCreator(new StaticInputCreator<InputSelfMonitorMetric>());
RegisterInputCreator(new StaticInputCreator<InputInternalMetrics>());
#if defined(__linux__) && !defined(__ANDROID__)
RegisterInputCreator(new StaticInputCreator<InputContainerStdio>());
RegisterInputCreator(new StaticInputCreator<InputFileSecurity>());
Expand Down Expand Up @@ -159,7 +159,7 @@ void PluginRegistry::LoadStaticPlugins() {

RegisterFlusherCreator(new StaticFlusherCreator<FlusherSLS>());
RegisterFlusherCreator(new StaticFlusherCreator<FlusherBlackHole>());
RegisterFlusherCreator(new StaticFlusherCreator<FlusherLocalFile>());
RegisterFlusherCreator(new StaticFlusherCreator<FlusherFile>());
}

void PluginRegistry::LoadDynamicPlugins(const set<string>& plugins) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "plugin/flusher/local_file/FlusherLocalFile.h"
#include "plugin/flusher/file/FlusherFile.h"

#include <spdlog/async.h>
#include <spdlog/sinks/rotating_file_sink.h>
Expand All @@ -24,16 +24,16 @@ using namespace std;

namespace logtail {

const string FlusherLocalFile::sName = "flusher_local_file";
const string FlusherFile::sName = "flusher_file";

bool FlusherLocalFile::Init(const Json::Value& config, Json::Value& optionalGoPipeline) {
bool FlusherFile::Init(const Json::Value& config, Json::Value& optionalGoPipeline) {
static uint32_t cnt = 0;
GenerateQueueKey(to_string(++cnt));
SenderQueueManager::GetInstance()->CreateQueue(mQueueKey, mPluginID, *mContext);

string errorMsg;
// FileName
if (!GetMandatoryStringParam(config, "FileName", mFileName, errorMsg)) {
// FilePath
if (!GetMandatoryStringParam(config, "FilePath", mFilePath, errorMsg)) {
PARAM_ERROR_RETURN(mContext->GetLogger(),
mContext->GetAlarm(),
errorMsg,
Expand All @@ -44,14 +44,14 @@ bool FlusherLocalFile::Init(const Json::Value& config, Json::Value& optionalGoPi
mContext->GetRegion());
}
// Pattern
GetMandatoryStringParam(config, "Pattern", mPattern, errorMsg);
// GetMandatoryStringParam(config, "Pattern", mPattern, errorMsg);
// MaxFileSize
GetMandatoryUIntParam(config, "MaxFileSize", mMaxFileSize, errorMsg);
// GetMandatoryUIntParam(config, "MaxFileSize", mMaxFileSize, errorMsg);
// MaxFiles
GetMandatoryUIntParam(config, "MaxFiles", mMaxFileSize, errorMsg);
// GetMandatoryUIntParam(config, "MaxFiles", mMaxFileSize, errorMsg);

// create file writer
auto file_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(mFileName, mMaxFileSize, mMaxFiles, true);
auto file_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(mFilePath, mMaxFileSize, mMaxFiles, true);
mFileWriter = std::make_shared<spdlog::async_logger>(
sName, file_sink, spdlog::thread_pool(), spdlog::async_overflow_policy::block);
mFileWriter->set_pattern(mPattern);
Expand All @@ -62,7 +62,7 @@ bool FlusherLocalFile::Init(const Json::Value& config, Json::Value& optionalGoPi
return true;
}

bool FlusherLocalFile::Send(PipelineEventGroup&& g) {
bool FlusherFile::Send(PipelineEventGroup&& g) {
if (g.IsReplay()) {
return SerializeAndPush(std::move(g));
} else {
Expand All @@ -72,19 +72,19 @@ bool FlusherLocalFile::Send(PipelineEventGroup&& g) {
}
}

bool FlusherLocalFile::Flush(size_t key) {
bool FlusherFile::Flush(size_t key) {
BatchedEventsList res;
mBatcher.FlushQueue(key, res);
return SerializeAndPush(std::move(res));
}

bool FlusherLocalFile::FlushAll() {
bool FlusherFile::FlushAll() {
vector<BatchedEventsList> res;
mBatcher.FlushAll(res);
return SerializeAndPush(std::move(res));
}

bool FlusherLocalFile::SerializeAndPush(PipelineEventGroup&& group) {
bool FlusherFile::SerializeAndPush(PipelineEventGroup&& group) {
string serializedData, errorMsg;
BatchedEvents g(std::move(group.MutableEvents()),
std::move(group.GetSizedTags()),
Expand All @@ -101,7 +101,7 @@ bool FlusherLocalFile::SerializeAndPush(PipelineEventGroup&& group) {
return true;
}

bool FlusherLocalFile::SerializeAndPush(BatchedEventsList&& groupList) {
bool FlusherFile::SerializeAndPush(BatchedEventsList&& groupList) {
string serializedData;
for (auto& group : groupList) {
string errorMsg;
Expand All @@ -116,7 +116,7 @@ bool FlusherLocalFile::SerializeAndPush(BatchedEventsList&& groupList) {
return true;
}

bool FlusherLocalFile::SerializeAndPush(vector<BatchedEventsList>&& groupLists) {
bool FlusherFile::SerializeAndPush(vector<BatchedEventsList>&& groupLists) {
for (auto& groupList : groupLists) {
SerializeAndPush(std::move(groupList));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace logtail {

class FlusherLocalFile : public Flusher {
class FlusherFile : public Flusher {
public:
static const std::string sName;

Expand All @@ -42,7 +42,7 @@ class FlusherLocalFile : public Flusher {
bool SerializeAndPush(std::vector<BatchedEventsList>&& groupLists);

std::shared_ptr<spdlog::logger> mFileWriter;
std::string mFileName;
std::string mFilePath;
std::string mPattern = "%v";
uint32_t mMaxFileSize = 1024 * 1024 * 10;
uint32_t mMaxFiles = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

#include "plugin/input/InputSelfMonitorMetric.h"
#include "plugin/input/InputInternalMetrics.h"

namespace logtail {

const std::string InputSelfMonitorMetric::sName = "input_self_monitor_metric";
const std::string InputInternalMetrics::sName = "input_internal_metrics";

bool GetEnabled(const Json::Value& rule) {
if (rule.isMember("Enable") && rule["Enable"].isBool())
Expand All @@ -39,7 +39,7 @@ void ParseSelfMonitorMetricRule(std::string&& ruleKey, const Json::Value& ruleJs
}
}

bool InputSelfMonitorMetric::Init(const Json::Value& config, Json::Value& optionalGoPipeline) {
bool InputInternalMetrics::Init(const Json::Value& config, Json::Value& optionalGoPipeline) {
ParseSelfMonitorMetricRule("Agent", config, mSelfMonitorMetricRules.mAgentMetricsRule);
ParseSelfMonitorMetricRule("Runner", config, mSelfMonitorMetricRules.mRunnerMetricsRule);
ParseSelfMonitorMetricRule("Pipeline", config, mSelfMonitorMetricRules.mPipelineMetricsRule);
Expand All @@ -49,12 +49,12 @@ bool InputSelfMonitorMetric::Init(const Json::Value& config, Json::Value& option
return true;
}

bool InputSelfMonitorMetric::Start() {
bool InputInternalMetrics::Start() {
SelfMonitorServer::GetInstance()->UpdateMetricPipeline(mContext, &mSelfMonitorMetricRules);
return true;
}

bool InputSelfMonitorMetric::Stop(bool isPipelineRemoving) {
bool InputInternalMetrics::Stop(bool isPipelineRemoving) {
if (isPipelineRemoving) {
SelfMonitorServer::GetInstance()->RemoveMetricPipeline();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace logtail {

class InputSelfMonitorMetric : public Input {
class InputInternalMetrics : public Input {
public:
static const std::string sName;

Expand Down

0 comments on commit b3c174d

Please sign in to comment.