feat(host): add telegraf config dir environmental variable (#22473)

This commit is contained in:
wanyaoqi
2025-05-04 08:59:54 +08:00
committed by GitHub
parent 4b77e1f4a7
commit 755b1931cc
+8 -1
View File
@@ -18,6 +18,8 @@ import (
"context"
"fmt"
"net/url"
"os"
"path"
"sort"
"strings"
@@ -343,7 +345,12 @@ func (s *STelegraf) GetConfig(kwargs map[string]interface{}) string {
}
func (s *STelegraf) GetConfigFile() string {
return "/etc/telegraf/telegraf.conf"
defaultTelegrafConfigDir := "/etc/telegraf"
telegrafConfigDir := os.Getenv("HOST_TELEGRAF_CONFIG_DIR")
if telegrafConfigDir == "" {
telegrafConfigDir = defaultTelegrafConfigDir
}
return path.Join(telegrafConfigDir, "telegraf.conf")
}
func (s *STelegraf) Reload(kwargs map[string]interface{}) error {