diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index 78687d286..cd12ff3c8 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -4,11 +4,13 @@ import ( "flag" "fmt" "log" + "net/http" "os" "os/signal" "strings" "syscall" + cfg "github.com/influxdata/config" "github.com/influxdata/telegraf/agent" "github.com/influxdata/telegraf/internal/config" _ "github.com/influxdata/telegraf/plugins/inputs/all" @@ -144,6 +146,13 @@ func main() { c.OutputFilters = outputFilters c.InputFilters = inputFilters err = c.LoadConfig(*fConfig) + + if c.Agent.ConfigPort != "" { + cf, _ := cfg.NewConfig(*fConfig, struct{}{}) + log.Printf("Starting configuration management service on port %s\n", c.Agent.ConfigPort) + go http.ListenAndServe(c.Agent.ConfigPort, cf.HTTP()) + } + if err != nil { log.Fatal(err) } diff --git a/internal/config/config.go b/internal/config/config.go index 9b35cd407..3e1de7880 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -92,6 +92,9 @@ type AgentConfig struct { // Quiet is the option for running in quiet mode Quiet bool Hostname string + + // ConfigPort is the location of the HTTP handlers for remotely changing config + ConfigPort string } // Inputs returns a list of strings of the configured inputs. @@ -175,6 +178,9 @@ var header = `# Telegraf configuration # Override default hostname, if empty use os.Hostname() hostname = "" + # Set configuration management port + config-port = "" + ############################################################################### # OUTPUTS #