From 88a1a9fd11c93842289ef0aaae29c11385f5ddcb Mon Sep 17 00:00:00 2001 From: Rory Z <16801068+Rory-Z@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:57:56 +0800 Subject: [PATCH] chore: change some default config Signed-off-by: Rory Z <16801068+Rory-Z@users.noreply.github.com> --- config/config.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 8515749..13f8f16 100644 --- a/config/config.go +++ b/config/config.go @@ -5,6 +5,7 @@ import ( "crypto/x509" "fmt" "os" + "strings" "sync" "github.com/prometheus/client_golang/prometheus" @@ -170,10 +171,14 @@ func (sc *SafeConfig) ReloadConfig(confFile string) (err error) { probe.Scheme = "tcp" } if probe.ClientID == "" { - probe.ClientID = "emqx_exporter_probe_" + fmt.Sprintf("%d", index) + hostname, _ := os.Hostname() + hostname = strings.Replace(hostname, ".", "-", -1) + probe.ClientID = "emqx-exporter-probe-" + hostname + fmt.Sprintf("%d", index) } if probe.Topic == "" { - probe.Topic = "emqx-exporter-probe-" + fmt.Sprintf("%d", index) + hostname, _ := os.Hostname() + hostname = strings.Replace(hostname, ".", "-", -1) + probe.Topic = "emqx-exporter-probe/" + hostname + "/" + fmt.Sprintf("%d", index) } if probe.KeepAlive == 0 { probe.KeepAlive = 30