diff --git a/CHANGELOG.md b/CHANGELOG.md index 860b3cca5b9..7353583ae16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## v0.8.5 [unreleased] +### Features + +- [Issue #1055](https://github.com/influxdb/influxdb/issues/1055). Allow + graphite and collectd input plugins to have separate binding address + ### Bugfixes - [Issue #821](https://github.com/influxdb/influxdb/issues/821). Don't diff --git a/api/collectd/api.go b/api/collectd/api.go index 19c8f017413..7796f57a37f 100644 --- a/api/collectd/api.go +++ b/api/collectd/api.go @@ -29,7 +29,7 @@ type Server struct { func NewServer(config *configuration.Configuration, coord api.Coordinator, clusterConfig *cluster.ClusterConfiguration) *Server { s := &Server{} - s.listenAddress = config.CollectdPortString() + s.listenAddress = config.CollectdBindString() s.database = config.CollectdDatabase s.coordinator = coord s.shutdown = make(chan bool, 1) diff --git a/api/graphite/api.go b/api/graphite/api.go index c3dc9b4bb7d..8137c0e031b 100644 --- a/api/graphite/api.go +++ b/api/graphite/api.go @@ -74,7 +74,7 @@ const max_queue = 20000 // TODO: check that database exists and create it if not func NewServer(config *configuration.Configuration, coord api.Coordinator, clusterConfig *cluster.ClusterConfiguration) *Server { self := &Server{} - self.listenAddress = config.GraphitePortString() + self.listenAddress = config.GraphiteBindString() self.database = config.GraphiteDatabase self.coordinator = coord self.writeSeries = make(chan Record, max_queue) diff --git a/config.sample.toml b/config.sample.toml index cf7fbb3705c..e003225ea04 100644 --- a/config.sample.toml +++ b/config.sample.toml @@ -40,6 +40,7 @@ read-timeout = "5s" # Configure the graphite api [input_plugins.graphite] enabled = false + # address = "0.0.0.0" # If not set, is actually set to bind-address. # port = 2003 # database = "" # store graphite data in this database # udp_enabled = true # enable udp interface on the same port as the tcp interface @@ -47,6 +48,7 @@ read-timeout = "5s" # Configure the collectd api [input_plugins.collectd] enabled = false + # address = "0.0.0.0" # If not set, is actually set to bind-address. # port = 25826 # database = "" # types.db can be found in a collectd installation or on github: diff --git a/configuration/configuration.go b/configuration/configuration.go index 6b1b1d0f085..7e40fa7a2eb 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -71,6 +71,7 @@ type ApiConfig struct { type GraphiteConfig struct { Enabled bool + Address string Port int Database string UdpEnabled bool `toml:"udp_enabled"` @@ -78,6 +79,7 @@ type GraphiteConfig struct { type CollectdInputConfig struct { Enabled bool + Address string Port int Database string TypesDB string `toml:"typesdb"` @@ -172,11 +174,13 @@ type Configuration struct { ApiReadTimeout time.Duration GraphiteEnabled bool + GraphiteAddress string GraphitePort int GraphiteDatabase string GraphiteUdpEnabled bool CollectdEnabled bool + CollectdAddress string CollectdPort int CollectdDatabase string CollectdTypesDB string @@ -316,11 +320,13 @@ func parseTomlConfiguration(filename string) (*Configuration, error) { ApiReadTimeout: apiReadTimeout, GraphiteEnabled: tomlConfiguration.InputPlugins.Graphite.Enabled, + GraphiteAddress: tomlConfiguration.InputPlugins.Graphite.Address, GraphitePort: tomlConfiguration.InputPlugins.Graphite.Port, GraphiteDatabase: tomlConfiguration.InputPlugins.Graphite.Database, GraphiteUdpEnabled: tomlConfiguration.InputPlugins.Graphite.UdpEnabled, CollectdEnabled: tomlConfiguration.InputPlugins.CollectdInput.Enabled, + CollectdAddress: tomlConfiguration.InputPlugins.CollectdInput.Address, CollectdPort: tomlConfiguration.InputPlugins.CollectdInput.Port, CollectdDatabase: tomlConfiguration.InputPlugins.CollectdInput.Database, CollectdTypesDB: tomlConfiguration.InputPlugins.CollectdInput.TypesDB, @@ -422,20 +428,28 @@ func (self *Configuration) ApiHttpSslPortString() string { return fmt.Sprintf("%s:%d", self.BindAddress, self.ApiHttpSslPort) } -func (self *Configuration) GraphitePortString() string { +func (self *Configuration) GraphiteBindString() string { if self.GraphitePort <= 0 { return "" } - return fmt.Sprintf("%s:%d", self.BindAddress, self.GraphitePort) + if self.GraphiteAddress != "" { + return fmt.Sprintf("%s:%d", self.GraphiteAddress, self.GraphitePort) + } else { + return fmt.Sprintf("%s:%d", self.BindAddress, self.GraphitePort) + } } -func (self *Configuration) CollectdPortString() string { +func (self *Configuration) CollectdBindString() string { if self.CollectdPort <= 0 { return "" } - return fmt.Sprintf("%s:%d", self.BindAddress, self.CollectdPort) + if self.CollectdAddress != "" { + return fmt.Sprintf("%s:%d", self.CollectdAddress, self.CollectdPort) + } else { + return fmt.Sprintf("%s:%d", self.BindAddress, self.CollectdPort) + } } func (self *Configuration) UdpInputPortString(port int) string { diff --git a/server/server.go b/server/server.go index ac51ea55b60..b452785af88 100644 --- a/server/server.go +++ b/server/server.go @@ -149,7 +149,7 @@ func (self *Server) ListenAndServe() error { } else if self.Config.GraphiteDatabase == "" { log.Warn(fail_reason("database name is invalid")) } else { - log.Info("Starting Graphite Listener on port %d", self.Config.GraphitePort) + log.Info("Starting Graphite Listener on %s", self.Config.GraphiteBindString()) go self.GraphiteApi.ListenAndServe() } } else { @@ -171,7 +171,7 @@ func (self *Server) ListenAndServe() error { } else if _, err := os.Stat(self.Config.CollectdTypesDB); err != nil { log.Warn(failReason("types.db is invalid")) } else { - log.Info("Starting Collectd Listener on port %d", self.Config.CollectdPort) + log.Info("Starting Collectd Listener on %s", self.Config.CollectdBindString()) go self.CollectdApi.ListenAndServe() } } else {