From bbc103305b57173cf37185bcad9c7eb381e09075 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sun, 6 Sep 2015 21:21:04 -0700 Subject: [PATCH 1/2] Support multiple Graphite inputs Fixes issue #3636 --- CHANGELOG.md | 1 + cmd/influxd/run/config.go | 1 - services/graphite/config.go | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3261d39ce21..26aa12a8239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ With this release InfluxDB is moving to Go 1.5. - [#3886](https://github.com/influxdb/influxdb/pull/3886): Prevent write timeouts due to lock contention in WAL - [#3574](https://github.com/influxdb/influxdb/issues/3574): Querying data node causes panic - [#3913](https://github.com/influxdb/influxdb/issues/3913): Convert meta shard owners to objects +- [#4026](https://github.com/influxdb/influxdb/pull/4026): Support multiple Graphite inputs. Fixes issue [#3636](https://github.com/influxdb/influxdb/issues/3636) - [#3927](https://github.com/influxdb/influxdb/issues/3927): Add WAL lock to prevent timing lock contention - [#3928](https://github.com/influxdb/influxdb/issues/3928): Write fails for multiple points when tag starts with quote - [#3901](https://github.com/influxdb/influxdb/pull/3901): Unblock relaxed write consistency level Thanks @takayuki! diff --git a/cmd/influxd/run/config.go b/cmd/influxd/run/config.go index 322b7bf5cbb..0b35fd95bf6 100644 --- a/cmd/influxd/run/config.go +++ b/cmd/influxd/run/config.go @@ -65,7 +65,6 @@ func NewConfig() *Config { c.HTTPD = httpd.NewConfig() c.Collectd = collectd.NewConfig() c.OpenTSDB = opentsdb.NewConfig() - c.Graphites = append(c.Graphites, graphite.NewConfig()) c.ContinuousQuery = continuous_querier.NewConfig() c.Retention = retention.NewConfig() diff --git a/services/graphite/config.go b/services/graphite/config.go index 298e5f7d139..01342767de1 100644 --- a/services/graphite/config.go +++ b/services/graphite/config.go @@ -73,6 +73,12 @@ func (c *Config) WithDefaults() *Config { if d.Protocol == "" { d.Protocol = DefaultProtocol } + if d.BatchSize == 0 { + d.BatchSize = DefaultBatchSize + } + if d.BatchTimeout == 0 { + d.BatchTimeout = toml.Duration(DefaultBatchTimeout) + } if d.ConsistencyLevel == "" { d.ConsistencyLevel = DefaultConsistencyLevel } From 332ce6481d3ac378dc2094a79529b71fe34032a4 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Tue, 8 Sep 2015 08:31:36 -0700 Subject: [PATCH 2/2] Removed unused Graphite NewConfig This function is not helpful for sections of the config that support multiple instances. --- services/graphite/config.go | 13 ------------- services/graphite/config_test.go | 14 +++++++------- services/graphite/service_test.go | 4 ++-- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/services/graphite/config.go b/services/graphite/config.go index 01342767de1..ba7381c1244 100644 --- a/services/graphite/config.go +++ b/services/graphite/config.go @@ -47,19 +47,6 @@ type Config struct { Separator string `toml:"separator"` } -// NewConfig returns a new Config with defaults. -func NewConfig() Config { - return Config{ - BindAddress: DefaultBindAddress, - Database: DefaultDatabase, - Protocol: DefaultProtocol, - BatchSize: DefaultBatchSize, - 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/graphite/config_test.go b/services/graphite/config_test.go index 635cf3909d9..3738a927cf4 100644 --- a/services/graphite/config_test.go +++ b/services/graphite/config_test.go @@ -51,7 +51,7 @@ tags=["region=us-east"] } func TestConfigValidateEmptyTemplate(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Templates = []string{""} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") @@ -64,7 +64,7 @@ func TestConfigValidateEmptyTemplate(t *testing.T) { } func TestConfigValidateTooManyField(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Templates = []string{"a measurement b c"} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") @@ -72,7 +72,7 @@ func TestConfigValidateTooManyField(t *testing.T) { } func TestConfigValidateTemplatePatterns(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Templates = []string{"*measurement"} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") @@ -85,7 +85,7 @@ func TestConfigValidateTemplatePatterns(t *testing.T) { } func TestConfigValidateFilter(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Templates = []string{".server measurement*"} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") @@ -103,7 +103,7 @@ func TestConfigValidateFilter(t *testing.T) { } func TestConfigValidateTemplateTags(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Templates = []string{"*.server measurement* foo"} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") @@ -126,7 +126,7 @@ func TestConfigValidateTemplateTags(t *testing.T) { } func TestConfigValidateDefaultTags(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Tags = []string{"foo"} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") @@ -149,7 +149,7 @@ func TestConfigValidateDefaultTags(t *testing.T) { } func TestConfigValidateFilterDuplicates(t *testing.T) { - c := graphite.NewConfig() + c := &graphite.Config{} c.Templates = []string{"foo measurement*", "foo .host.measurement"} if err := c.Validate(); err == nil { t.Errorf("config validate expected error. got nil") diff --git a/services/graphite/service_test.go b/services/graphite/service_test.go index b7e59c49271..f041dfd95cc 100644 --- a/services/graphite/service_test.go +++ b/services/graphite/service_test.go @@ -19,7 +19,7 @@ func Test_ServerGraphiteTCP(t *testing.T) { now := time.Now().UTC().Round(time.Second) - config := graphite.NewConfig() + config := graphite.Config{} config.Database = "graphitedb" config.BatchSize = 0 // No batching. config.BatchTimeout = toml.Duration(time.Second) @@ -87,7 +87,7 @@ func Test_ServerGraphiteUDP(t *testing.T) { now := time.Now().UTC().Round(time.Second) - config := graphite.NewConfig() + config := graphite.Config{} config.Database = "graphitedb" config.BatchSize = 0 // No batching. config.BatchTimeout = toml.Duration(time.Second)