Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration changes for self-monitoring #2165

Merged
merged 2 commits into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- [#2156](https://github.com/influxdb/influxdb/pull/2156): Propagate error when resolving UDP address in Graphite UDP server.
- [#2163](https://github.com/influxdb/influxdb/pull/2163): Fix up paths for default data and run storage.
- [#2164](https://github.com/influxdb/influxdb/pull/2164): Append STDOUT/STDERR in initscript.
- [#2165](https://github.com/influxdb/influxdb/pull/2165): Better name for config section for stats and diags.
- [#2165](https://github.com/influxdb/influxdb/pull/2165): Monitoring database and retention policy are not configurable.

## v0.9.0-rc19 [2015-04-01]

Expand Down
16 changes: 6 additions & 10 deletions cmd/influxd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ type Config struct {
RaftTracing bool `toml:"raft-tracing"`
} `toml:"logging"`

Statistics struct {
Enabled bool `toml:"enabled"`
Database string `toml:"database"`
RetentionPolicy string `toml:"retention-policy"`
WriteInterval Duration `toml:"write-interval"`
}
Monitoring struct {
Enabled bool `toml:"enabled"`
WriteInterval Duration `toml:"write-interval"`
} `toml:"monitoring"`

ContinuousQuery struct {
// when continuous queries are run we'll automatically recompute previous intervals
Expand Down Expand Up @@ -195,10 +193,8 @@ func NewConfig() (*Config, error) {
c.ContinuousQuery.Disable = false
c.ReportingDisabled = false

c.Statistics.Enabled = false
c.Statistics.Database = "_internal"
c.Statistics.RetentionPolicy = "default"
c.Statistics.WriteInterval = Duration(1 * time.Minute)
c.Monitoring.Enabled = false
c.Monitoring.WriteInterval = Duration(1 * time.Minute)

// Detect hostname (or set to localhost).
if c.Hostname, _ = os.Hostname(); c.Hostname == "" {
Expand Down
10 changes: 4 additions & 6 deletions cmd/influxd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func TestParseConfig(t *testing.T) {
t.Fatalf("cluster dir mismatch: %v", c.Cluster.Dir)
}

if c.Statistics.WriteInterval.String() != "1m0s" {
t.Fatalf("Statistics.WriteInterval mismatch: %v", c.Statistics.WriteInterval)
if c.Monitoring.WriteInterval.String() != "1m0s" {
t.Fatalf("Monitoring.WriteInterval mismatch: %v", c.Monitoring.WriteInterval)
}

// TODO: UDP Servers testing.
Expand All @@ -158,7 +158,7 @@ func TestParseConfig(t *testing.T) {

func TestEncodeConfig(t *testing.T) {
c := main.Config{}
c.Statistics.WriteInterval = main.Duration(time.Minute)
c.Monitoring.WriteInterval = main.Duration(time.Minute)
buf := new(bytes.Buffer)
if err := toml.NewEncoder(buf).Encode(&c); err != nil {
t.Fatal("Failed to encode: ", err)
Expand Down Expand Up @@ -191,10 +191,8 @@ enabled = true
write-tracing = true
raft-tracing = true

[statistics]
[monitoring]
enabled = true
database = "_internal"
retention-policy = "default"
write-interval = "1m"

# Configure the admin server
Expand Down
4 changes: 3 additions & 1 deletion cmd/influxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ var (

// Various constants used by the main package.
const (
messagingClientFile string = "messaging"
messagingClientFile string = "messaging"
monitoringDatabase string = "_influxdb"
monitoringRetentionPolicy string = "default"
)

func main() {
Expand Down
12 changes: 6 additions & 6 deletions cmd/influxd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,20 @@ func Run(config *Config, join, version string) (*messaging.Broker, *influxdb.Ser
}

// Start up self-monitoring if enabled.
if config.Statistics.Enabled {
database := config.Statistics.Database
policy := config.Statistics.RetentionPolicy
interval := time.Duration(config.Statistics.WriteInterval)
if config.Monitoring.Enabled {
database := monitoringDatabase
policy := monitoringRetentionPolicy
interval := time.Duration(config.Monitoring.WriteInterval)

// Ensure database exists.
if err := s.CreateDatabaseIfNotExists(database); err != nil {
log.Fatalf("failed to create database %s for internal statistics: %s", database, err.Error())
log.Fatalf("failed to create database %s for internal monitoring: %s", database, err.Error())
}

// Ensure retention policy exists.
rp := influxdb.NewRetentionPolicy(policy)
if err := s.CreateRetentionPolicyIfNotExists(database, rp); err != nil {
log.Fatalf("failed to create retention policy for internal statistics: %s", err.Error())
log.Fatalf("failed to create retention policy for internal monitoring: %s", err.Error())
}

s.StartSelfMonitoring(database, policy, interval)
Expand Down
10 changes: 4 additions & 6 deletions etc/config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ port = 8087
write-tracing = false # If true, enables detailed logging of the write system.
raft-tracing = false # If true, enables detailed logging of Raft consensus.

# InfluxDB can store statistics about itself. This is useful for monitoring purposes.
# This feature is disabled by default, but if enabled, these statistics can be queried
# as any other data.
[statistics]
# InfluxDB can store statistical and diagnostic information about itself. This is useful for
# monitoring purposes. This feature is disabled by default, but if enabled, these data can be
# queried like any other data.
[monitoring]
enabled = false
database = "_internal" # The database to which the data is written.
retention-policy = "default" # The retention policy within the database.
write-interval = "1m" # Period between writing the data.