Skip to content

Commit

Permalink
add GetAgentPrometheusAuthorizationPath
Browse files Browse the repository at this point in the history
  • Loading branch information
quzard committed Dec 31, 2024
1 parent c0cec39 commit 94cd582
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions core/app_config/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,23 @@ std::string GetAgentLogDir() {
return dir;
}

std::string GetAgentPrometheusAuthorizationPath() {
static std::string dir;
if (!dir.empty()) {
return dir;
}
#if defined(APSARA_UNIT_TEST_MAIN)
dir = GetProcessExecutionDir();
#else
if (BOOL_FLAG(logtail_mode)) {
dir = GetProcessExecutionDir();
} else {
return AppConfig::GetInstance()->GetLoongcollectorConfDir();
}
#endif
return dir;
}

std::string GetAgentGoLogConfDir() {
static std::string dir;
if (!dir.empty()) {
Expand Down
1 change: 1 addition & 0 deletions core/app_config/AppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ std::string GetAgentThirdPartyDir();

std::string GetAgentGoCheckpointDir();
std::string GetAgentGoLogConfDir();
std::string GetAgentPrometheusAuthorizationPath();
std::string GetAgentConfigFile();
std::string GetAgentAppInfoFile();
std::string GetAdhocCheckpointDirPath();
Expand Down
1 change: 1 addition & 0 deletions core/go_pipeline/LogtailPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ LogtailPlugin::LogtailPlugin() {
mPluginCfg["LoongcollectorVersionTag"] = GetVersionTag();
mPluginCfg["LoongcollectorCheckPointFile"] = GetGoPluginCheckpoint();
mPluginCfg["LoongcollectorThirdPartyDir"] = GetAgentThirdPartyDir();
mPluginCfg["PrometheusAuthorizationPath"] = GetAgentPrometheusAuthorizationPath();
mPluginCfg["HostIP"] = LoongCollectorMonitor::mIpAddr;
mPluginCfg["Hostname"] = LoongCollectorMonitor::mHostname;
mPluginCfg["EnableContainerdUpperDirDetect"] = BOOL_FLAG(enable_containerd_upper_dir_detect);
Expand Down
2 changes: 1 addition & 1 deletion core/plugin/flusher/sls/SLSClientManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include "app_config/AppConfig.h"
#include "common/Flags.h"
#include "common/MachineInfoUtil.h"
#include "common/HashUtil.h"
#include "common/MachineInfoUtil.h"
#include "common/StringTools.h"
#include "common/http/Constant.h"
#include "common/http/Curl.h"
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/global_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type GlobalConfig struct {
DefaultLogQueueSize int
DefaultLogGroupQueueSize int
Tags map[string]string
// Directory to store prometheus configuration file.
PrometheusAuthorizationPath string
// Directory to store loongcollector data, such as checkpoint, etc.
LoongcollectorConfDir string
// Directory to store loongcollector log config.
Expand Down Expand Up @@ -82,6 +84,7 @@ func newGlobalConfig() (cfg GlobalConfig) {
LoongcollectorDataDir: "./data/",
LoongcollectorDebugDir: "./debug/",
LoongcollectorThirdPartyDir: "./thirdparty/",
PrometheusAuthorizationPath: "./conf/",
DelayStopSec: 300,
}
return
Expand Down
2 changes: 1 addition & 1 deletion plugins/input/prometheus/input_prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (p *ServiceStaticPrometheus) Init(context pipeline.Context) (int, error) {
case p.Yaml != "":
detail = []byte(p.Yaml)
if p.AuthorizationPath == "" {
p.AuthorizationPath = config.LoongcollectorGlobalConfig.LoongcollectorConfDir
p.AuthorizationPath = config.LoongcollectorGlobalConfig.PrometheusAuthorizationPath
}
case p.ConfigFilePath != "":
f, err := os.Open(p.ConfigFilePath)
Expand Down

0 comments on commit 94cd582

Please sign in to comment.