Merge pull request #55 from kongfei605/prom_support_env

support env var for prom instances
This commit is contained in:
kongfei605 2022-06-28 11:56:07 +08:00 committed by GitHub
commit d9455a13ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -57,6 +57,11 @@ func (ins *Instance) Init() error {
} else if len(ins.URLs) == 0 {
return types.ErrInstancesEmpty
}
for i, u := range ins.URLs {
ins.URLs[i] = strings.Replace(u, "$hostname", config.Config.GetHostname(), -1)
ins.URLs[i] = strings.Replace(u, "$ip", config.Config.Global.IP, -1)
ins.URLs[i] = os.Expand(u, config.GetEnv)
}
if ins.Timeout <= 0 {
ins.Timeout = config.Duration(time.Second * 3)