Allow users to tell telegraf Agent not to include host tag

closes #848
This commit is contained in:
Cameron Sparr
2016-03-21 15:33:19 -06:00
parent 5917a42997
commit f543dbb42f
4 changed files with 25 additions and 10 deletions

View File

@@ -27,17 +27,19 @@ func NewAgent(config *config.Config) (*Agent, error) {
Config: config,
}
if a.Config.Agent.Hostname == "" {
hostname, err := os.Hostname()
if err != nil {
return nil, err
if !a.Config.Agent.OmitHostname {
if a.Config.Agent.Hostname == "" {
hostname, err := os.Hostname()
if err != nil {
return nil, err
}
a.Config.Agent.Hostname = hostname
}
a.Config.Agent.Hostname = hostname
config.Tags["host"] = a.Config.Agent.Hostname
}
config.Tags["host"] = a.Config.Agent.Hostname
return a, nil
}