Skip to content

Commit

Permalink
Merge pull request #2829 from influxdb/reenable_graphite
Browse files Browse the repository at this point in the history
Re-enable Graphite support
  • Loading branch information
otoolep committed Jun 9, 2015
2 parents e35c391 + 4769d65 commit c6c4010
Show file tree
Hide file tree
Showing 9 changed files with 532 additions and 442 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [2824](https://github.com/influxdb/influxdb/pull/2824) -- Add missing call to WaitGroup.Done in execConn. Thanks @liyichao
- [2823](https://github.com/influxdb/influxdb/pull/2823) -- Convert OpenTSDB to a service.
- [2838](https://github.com/influxdb/influxdb/pull/2838) -- Set auto-created retention policy period to infinite.
- [2829](https://github.com/influxdb/influxdb/pull/2829) -- Re-enable Graphite support as a new Service-style component.

## v0.9.0-rc32 [2015-06-07]

Expand Down
1 change: 1 addition & 0 deletions cmd/influxd/run/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (s *Server) appendGraphiteService(c graphite.Config) {
return
}
srv := graphite.NewService(c)
srv.PointsWriter = s.PointsWriter
s.Services = append(s.Services, srv)
}

Expand Down
58 changes: 49 additions & 9 deletions services/graphite/config.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,74 @@
package graphite

import "strings"
import (
"strings"

"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/toml"
)

const (
// DefaultBindAddress is the default binding interface if none is specified.
DefaultBindAddress = ":2003"

// DefaultDatabase is the default database if none is specified.
DefaultDatabase = "graphite"

// DefaultNameSeparator represents the default field separator.
DefaultNameSeparator = "."

// DefaultNamePosition represents the default location of the name.
DefaultNamePosition = "last"

// DefaultProtocol is the default IP protocol used by the Graphite input.
DefaultProtocol = "tcp"

// DefaultConsistencyLevel is the default write consistency for the Graphite input.
DefaultConsistencyLevel = "one"
)

// Config represents the configuration for Graphite endpoints.
type Config struct {
BindAddress string `toml:"bind-address"`
Database string `toml:"database"`
Enabled bool `toml:"enabled"`
Protocol string `toml:"protocol"`
NamePosition string `toml:"name-position"`
NameSeparator string `toml:"name-separator"`
BindAddress string `toml:"bind-address"`
Database string `toml:"database"`
Enabled bool `toml:"enabled"`
Protocol string `toml:"protocol"`
NamePosition string `toml:"name-position"`
NameSeparator string `toml:"name-separator"`
BatchSize int `toml:"batch-size"`
BatchTimeout toml.Duration `toml:"batch-timeout"`
ConsistencyLevel string `toml:"consistency-level"`
}

// NewConfig returns a new Config with defaults.
func NewConfig() Config {
return Config{
Database: DefaultDatabase,
NameSeparator: DefaultNameSeparator,
BindAddress: DefaultBindAddress,
Database: DefaultDatabase,
Protocol: DefaultProtocol,
NamePosition: DefaultNamePosition,
NameSeparator: DefaultNameSeparator,
ConsistencyLevel: DefaultConsistencyLevel,
}
}

// LastEnabled returns whether the server should interpret the last field as "name".
func (c *Config) LastEnabled() bool {
return c.NamePosition == strings.ToLower("last")
}

// ConsistencyAsEnum returns the enumerated write consistency level.
func (c *Config) ConsistencyAsEnum() cluster.ConsistencyLevel {
switch strings.ToLower(c.ConsistencyLevel) {
case "any":
return cluster.ConsistencyLevelAny
case "one":
return cluster.ConsistencyLevelOne
case "quorum":
return cluster.ConsistencyLevelQuorum
case "all":
return cluster.ConsistencyLevelAll
default:
return cluster.ConsistencyLevelOne
}
}
41 changes: 27 additions & 14 deletions services/graphite/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,47 @@ package graphite_test

import (
"testing"
"time"

"github.com/BurntSushi/toml"
"github.com/influxdb/influxdb/services/httpd"
"github.com/influxdb/influxdb/services/graphite"
)

func TestConfig_Parse(t *testing.T) {
// Parse configuration.
var c httpd.Config
var c graphite.Config
if _, err := toml.Decode(`
bind-address = ":8080"
auth-enabled = true
log-enabled = true
write-tracing = true
pprof-enabled = true
database = "mydb"
enabled = true
protocol = "tcp"
name-position = "first"
name-separator = "."
batch-size=100
batch-timeout="1s"
consistency-level="one"
`, &c); err != nil {
t.Fatal(err)
}

// Validate configuration.
if c.BindAddress != ":8080" {
t.Fatalf("unexpected bind address: %s", c.BindAddress)
} else if c.AuthEnabled != true {
t.Fatalf("unexpected auth enabled: %v", c.AuthEnabled)
} else if c.LogEnabled != true {
t.Fatalf("unexpected log enabled: %v", c.LogEnabled)
} else if c.WriteTracing != true {
t.Fatalf("unexpected write tracing: %v", c.WriteTracing)
} else if c.PprofEnabled != true {
t.Fatalf("unexpected pprof enabled: %v", c.PprofEnabled)
} else if c.Database != "mydb" {
t.Fatalf("unexpected database selected: %s", c.Database)
} else if c.Enabled != true {
t.Fatalf("unexpected graphite enabled: %v", c.Enabled)
} else if c.Protocol != "tcp" {
t.Fatalf("unexpected graphite protocol: %s", c.Protocol)
} else if c.NamePosition != "first" {
t.Fatalf("unexpected graphite name position: %s", c.NamePosition)
} else if c.NameSeparator != "." {
t.Fatalf("unexpected graphite name separator: %s", c.NameSeparator)
} else if c.BatchSize != 100 {
t.Fatalf("unexpected graphite batch size: %d", c.BatchSize)
} else if time.Duration(c.BatchTimeout) != time.Second {
t.Fatalf("unexpected graphite batch timeout: %v", c.BatchTimeout)
} else if c.ConsistencyLevel != "one" {
t.Fatalf("unexpected graphite consistency setting: %s", c.ConsistencyLevel)
}
}
140 changes: 0 additions & 140 deletions services/graphite/graphite.go

This file was deleted.

Loading

0 comments on commit c6c4010

Please sign in to comment.