From 4f8b0aca9a563977e5024ea5e3ae63fe2e4118fe Mon Sep 17 00:00:00 2001 From: Nicholas Katsaros Date: Thu, 5 Nov 2015 16:42:21 -0500 Subject: [PATCH] Add graphite and udp services to the default config generator --- cmd/influxd/run/config.go | 2 ++ services/graphite/config.go | 15 ++++++++++++++- services/udp/config.go | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/cmd/influxd/run/config.go b/cmd/influxd/run/config.go index 2a3d4e66e3..119e347c41 100644 --- a/cmd/influxd/run/config.go +++ b/cmd/influxd/run/config.go @@ -69,8 +69,10 @@ func NewConfig() *Config { c.Monitor = monitor.NewConfig() c.Subscriber = subscriber.NewConfig() c.HTTPD = httpd.NewConfig() + c.Graphites = []graphite.Config{graphite.NewConfig()} c.Collectd = collectd.NewConfig() c.OpenTSDB = opentsdb.NewConfig() + c.UDPs = []udp.Config{udp.NewConfig()} c.ContinuousQuery = continuous_querier.NewConfig() c.Retention = retention.NewConfig() diff --git a/services/graphite/config.go b/services/graphite/config.go index a1fe7a79d3..ff589974d0 100644 --- a/services/graphite/config.go +++ b/services/graphite/config.go @@ -38,9 +38,9 @@ const ( // Config represents the configuration for Graphite endpoints. type Config struct { + Enabled bool `toml:"enabled"` BindAddress string `toml:"bind-address"` Database string `toml:"database"` - Enabled bool `toml:"enabled"` Protocol string `toml:"protocol"` BatchSize int `toml:"batch-size"` BatchPending int `toml:"batch-pending"` @@ -51,6 +51,19 @@ type Config struct { Separator string `toml:"separator"` } +func NewConfig() Config { + return Config{ + BindAddress: DefaultBindAddress, + Database: DefaultDatabase, + Protocol: DefaultProtocol, + BatchSize: DefaultBatchSize, + BatchPending: DefaultBatchPending, + BatchTimeout: toml.Duration(DefaultBatchTimeout), + ConsistencyLevel: DefaultConsistencyLevel, + Separator: DefaultSeparator, + } +} + // WithDefaults takes the given config and returns a new config with any required // default values set. func (c *Config) WithDefaults() *Config { diff --git a/services/udp/config.go b/services/udp/config.go index aea15bc623..4325f81d27 100644 --- a/services/udp/config.go +++ b/services/udp/config.go @@ -7,9 +7,15 @@ import ( ) const ( + // DefaultBindAddress is the default binding interface if none is specified. + DefaultBindAddress = ":8089" + // DefaultDatabase is the default database for UDP traffic. DefaultDatabase = "udp" + // DefaultRetentionPolicy is the default retention policy used for writes. + DefaultRetentionPolicy = "" + // DefaultBatchSize is the default UDP batch size. DefaultBatchSize = 1000 @@ -31,6 +37,17 @@ type Config struct { BatchTimeout toml.Duration `toml:"batch-timeout"` } +func NewConfig() Config { + return Config{ + BindAddress: DefaultBindAddress, + Database: DefaultDatabase, + RetentionPolicy: DefaultRetentionPolicy, + BatchSize: DefaultBatchSize, + BatchPending: DefaultBatchPending, + BatchTimeout: toml.Duration(DefaultBatchTimeout), + } +} + // WithDefaults takes the given config and returns a new config with any required // default values set. func (c *Config) WithDefaults() *Config {