fix(host): telegraf listen on local ipv4 address explicitly

Ensure telegraf listen on local IPv4 address explicityly and host send
metrics to telegraf local IPv4 address explicityly.
This commit is contained in:
Qiu Jian
2020-12-19 15:33:10 +08:00
parent 638b64867d
commit ee16a43865
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ import (
)
const (
TelegrafServer = "http://localhost:8087/write"
TelegrafServer = "http://127.0.0.1:8087/write"
MeasurementsPrefix = "vm_"
)
+2 -2
View File
@@ -176,7 +176,7 @@ func (s *STelegraf) GetConfig(kwargs map[string]interface{}) string {
conf += " collect_memstats = false\n"
conf += "\n"
conf += "[[inputs.http_listener]]\n"
conf += " service_address = \"localhost:8087\"\n"
conf += " service_address = \"127.0.0.1:8087\"\n"
conf += "\n"
return conf
}
@@ -210,7 +210,7 @@ func (s *STelegraf) BgReloadConf(kwargs map[string]interface{}) {
func (s *STelegraf) ReloadTelegraf() error {
log.Infof("Start reolad telegraf...")
telegrafReoladUrl := "http://localhost:8087/reload"
telegrafReoladUrl := "http://127.0.0.1:8087/reload"
_, _, err := httputils.JSONRequest(
httputils.GetDefaultClient(), context.Background(),
"POST", telegrafReoladUrl, nil, nil, false,