config

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config handles configuration parsing.

Index

Constants

View Source
const (
	// Time
	Second uint32 = 1
	Minute        = 60 * Second
	Hour          = 60 * Minute
	Day           = 24 * Hour
)

Measures

View Source
const (
	// Default time interval for all metrics in seconds.
	DefaultInterval uint32 = 10 * Second
	// Default hit limit to a rule in an interval
	DefaultIntervalHitLimit uint32 = 512
	// Default period for all metrics in seconds.
	DefaultPeriod uint32 = 1 * Day
	// Default metric expiration.
	DefaultExpiration uint32 = 7 * Day
	// Default filter offset to query history metrics.
	DefaultFilterOffset float64 = 0.01
	// Default filter times to query history metrics.
	DefaultFilterTimes int = 4
	// Default value of alerting interval.
	DefaultAlerterInterval uint32 = 20 * Minute
	// Default value of alerting check interval.
	DefaultAlerterCheckInterval uint32 = Minute
	// Default value of number of alerts after which we should send notifications.
	DefaultNotifyAfter = 1
	// Default value of alert times limit in one day for the same metric
	DefaultAlerterOneDayLimit uint32 = 10
	// Default value of least count.
	DefaultLeastCount uint32 = 5 * Minute / DefaultInterval
	// Default alerting silent time range.
	DefaultSilentTimeStart int = 0
	DefaultSilentTimeEnd   int = 6
	// Default language for webapp.
	DefaultWebappLanguage string = "en"
	// Default detection warning timeout, in ms.
	DefaultDetectionWarningTimeout = 300
	// Default alert command execution timeout, in seconds.
	DefaultAlertExecCommandTimeout = 5
	// Default trending factor for low level rules.
	DefaultTrendingFactorLowLevel float64 = 0.1
	// Default trending factor for middle level rules.
	DefaultTrendingFactorMiddleLevel float64 = 0.2
	// Default trending factor for high level rules.
	DefaultTrendingFactorHighLevel float64 = 0.3
	// Default idle metric check interval, in seconds.
	DefaultIdleMetricCheckInterval = 60
	// Default idle metric track limit.
	DefaultIdleMetricTrackLimit = 60
	// Default bool if detector should use recent data.
	DefaultUsingRecentDataPoints = true
)

Defaults

View Source
const (
	// Max value for the number of DefaultThresholdMaxs.
	MaxNumDefaultThresholdMaxs = 8
	// Max value for the number of DefaultThresholdMins.
	MaxNumDefaultThresholdMins = 8
	// Max value for the number of FillBlankZeros.
	MaxFillBlankZerosLen = 8
	// Min value for the expiration to period.
	MinExpirationNumToPeriod uint32 = 5
	// Min value for the period.
	MinPeriod uint32 = 1 * Hour // 1h
)

Limitations

Variables

View Source
var (
	// Error
	ErrInterval                        = errors.New("interval should be an integer between 1s~10min")
	ErrPeriod                          = errors.New("period should be an integer greater than interval")
	ErrPeriodTooSmall                  = errors.New("period should be at least 1 hour")
	ErrExpiration                      = errors.New("expiration should be an integer greater than (or equal to) 5 * period")
	ErrExpirationDivPeriodClean        = errors.New("expiration should be a multiple of period")
	ErrDetectorPort                    = errors.New("invalid detector.port")
	ErrDetectorTrendingFactor          = errors.New("detector.trending_factor should be a float between 0 and 1")
	ErrDetectorFilterTimes             = errors.New("detector.filter_times should be smaller")
	ErrDetectorDefaultThresholdMaxsLen = errors.New("detector.default_threshold_maxs should have up to 8 items")
	ErrDetectorDefaultThresholdMinsLen = errors.New("detector.default_threshold_mins should have up to 8 items")
	ErrDetectorDefaultThresholdMaxZero = errors.New("detector.default_threshold_maxs should not contain zeros")
	ErrDetectorDefaultThresholdMinZero = errors.New("detector.default_threshold_mins should not contain zeros")
	ErrDetectorFillBlankZerosLen       = errors.New("detector.fill_blank_zeros should have up to 8 items")
	ErrWebappPort                      = errors.New("invalid webapp.port")
	ErrWebappLanguage                  = errors.New("invalid webapp language")
	ErrAlerterInterval                 = errors.New("alerter.interval should be greater than 0")
	ErrAlerterOneDayLimit              = errors.New("alerter.one_day_limit should be greater than 0")
	ErrAlerterDefaultSilentTimeRange   = errors.New("alerter.default_silent_time_range should be 2 numbers between 0~24")
	// Warn
	ErrAlerterCommandEmpty = errors.New("alerter.command is empty")
)

Errors

View Source
var WebappSupportedLanguages = []string{"en", "zh"}

WebappSupportedLanguages lists webapp supported languages.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval   uint32         `json:"interval" yaml:"interval"`
	Period     uint32         `json:"period" yaml:"period"`
	Expiration uint32         `json:"expiration" yaml:"expiration"`
	Storage    configStorage  `json:"storage" yaml:"storage"`
	Detector   configDetector `json:"detector" yaml:"detector"`
	Webapp     configWebapp   `json:"webapp" yaml:"webapp"`
	Alerter    configAlerter  `json:"alerter" yaml:"alerter"`
	Notifier   configNotifier `json:"notifier" yaml:"notifier"`
}

Config is the configuration container.

func New

func New() *Config

New creates a Config with default values.

func (*Config) Copy

func (c *Config) Copy() *Config

Copy config.

func (*Config) UpdateWithYamlFile added in v0.2.0

func (c *Config) UpdateWithYamlFile(fileName string) error

UpdateWithYamlFile updates the config from a yaml file.

func (*Config) Validate

func (c *Config) Validate() error

Validate config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL