From d5fa94c8846e30df7c79f1343c43ce34b00cb55f Mon Sep 17 00:00:00 2001 From: henryzhx8 Date: Thu, 16 May 2024 09:58:51 +0800 Subject: [PATCH] allow empty endpoint in enterprise flusher_sls to avoid unsuccessful load of config (#1486) --- core/flusher/FlusherSLS.cpp | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/core/flusher/FlusherSLS.cpp b/core/flusher/FlusherSLS.cpp index 9d740b68a3..3d8d1683b7 100644 --- a/core/flusher/FlusherSLS.cpp +++ b/core/flusher/FlusherSLS.cpp @@ -94,19 +94,33 @@ bool FlusherSLS::Init(const Json::Value& config, Json::Value& optionalGoPipeline } // Endpoint - if (!GetMandatoryStringParam(config, "Endpoint", mEndpoint, errorMsg)) { - PARAM_ERROR_RETURN(mContext->GetLogger(), - mContext->GetAlarm(), - errorMsg, - sName, - mContext->GetConfigName(), - mContext->GetProjectName(), - mContext->GetLogstoreName(), - mContext->GetRegion()); - } - mEndpoint = TrimString(mEndpoint); - if (!mEndpoint.empty()) { - Sender::Instance()->AddEndpointEntry(mRegion, StandardizeEndpoint(mEndpoint, mEndpoint)); +#ifdef __ENTERPRISE__ + if (!GetOptionalStringParam(config, "Endpoint", mEndpoint, errorMsg)) { + PARAM_WARNING_IGNORE(mContext->GetLogger(), + mContext->GetAlarm(), + errorMsg, + sName, + mContext->GetConfigName(), + mContext->GetProjectName(), + mContext->GetLogstoreName(), + mContext->GetRegion()); + } else { +#else + if (!GetMandatoryStringParam(config, "Endpoint", mEndpoint, errorMsg)) { + PARAM_ERROR_RETURN(mContext->GetLogger(), + mContext->GetAlarm(), + errorMsg, + sName, + mContext->GetConfigName(), + mContext->GetProjectName(), + mContext->GetLogstoreName(), + mContext->GetRegion()); + } else { +#endif + mEndpoint = TrimString(mEndpoint); + if (!mEndpoint.empty()) { + Sender::Instance()->AddEndpointEntry(mRegion, StandardizeEndpoint(mEndpoint, mEndpoint)); + } } #ifdef __ENTERPRISE__ }