influxdb/monitor/config.go

45 lines
1.1 KiB
Go
Raw Normal View History

2015-09-01 03:17:13 +00:00
package monitor
import (
2016-05-03 23:34:17 +00:00
"errors"
2015-09-01 03:17:13 +00:00
"time"
"github.com/influxdata/influxdb/toml"
2015-09-01 03:17:13 +00:00
)
const (
// DefaultStoreEnabled is whether the system writes gathered information in
// an InfluxDB system for historical analysis.
DefaultStoreEnabled = true
// DefaultStoreDatabase is the name of the database where gathered information is written
DefaultStoreDatabase = "_internal"
// DefaultStoreInterval is the period between storing gathered information.
DefaultStoreInterval = 10 * time.Second
2015-09-01 03:17:13 +00:00
)
// Config represents the configuration for the monitor service.
type Config struct {
StoreEnabled bool `toml:"store-enabled"`
StoreDatabase string `toml:"store-database"`
StoreInterval toml.Duration `toml:"store-interval"`
2015-09-01 03:17:13 +00:00
}
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
return Config{
StoreEnabled: true,
StoreDatabase: DefaultStoreDatabase,
StoreInterval: toml.Duration(DefaultStoreInterval),
2015-09-01 03:17:13 +00:00
}
}
2016-05-03 23:34:17 +00:00
// Validate validates that the configuration is acceptable.
func (c Config) Validate() error {
if c.StoreInterval <= 0 {
return errors.New("monitor store interval must be positive")
}
return nil
}