Documentation ¶
Overview ¶
Package config handles configuration parser and container.
Example ¶
Configuration is in JSON file, for example:
{ "interval": 10, "period": 86400, "expiration": 604800, "storage": { "path": "storage/" }, "detector": { "port": 2015, "trendingFactor": 0.1, "filterOffset": 0.01, "filterTimes": 4, "leastCount": 30, "blacklist": ["statsd.*"], "intervalHitLimit": 100, "defaultThresholdMaxs": {"timer.mean_90": 300}, "defaultThresholdMins": {}, "fillBlankZeros": ["counter.*.exc"] }, "webapp": { "port": 2016, "auth": ["user", "pass"], "static": "static/dist" }, "alerter": { "command": "", "workers": 4, "interval": 1200, "oneDayLimit": 5, "defaultSilentTimeRange": [0, 6] } }
To use config file with banshee:
banshee -c path/to/config.json
Documents ¶
The documents for each configuration item with default values:
interval // All metrics incoming interval (in seconds), default: 10 period // All metrics period (in seconds), default: 86400 (1 day) expiration // All metrics expiration (in seconds), default: 604800 (7 days) storage.path // Storage directory path. detector.port // Detector tcp port to listen. detector.trendingFactor // Detection weighted moving factor, should be a number between 0 and 1, default: 0.1 detector.filterOffset // Offset to filter history data, as a percentage to period, default: 0.01 detector.filterTimes // Number of times to filter history data, default: 4 (4 days history) detector.leastCount // Least count to start detection. default: 30 detector.blacklist // Incoming metrics blacklist, each one should be a wildcard pattern, default: [] detector.intervalHitLimit // Limitation for number of filtered metrics for each rule in one interval. default: 100 detector.defaultThresholdMaxs // Default thresholdMax for all rules, a wildcard pattern to number map. default: {} detector.defaultThresholdMins // Default thresholdMin for all rules, a wildcard pattern to number map. default: {} detector.filterBlankZeros // Detector will fill metric blanks with zeros if it matches any of these wildcard patterns. default: [] webapp.port // Webapp http port to listen. webapp.auth // Webapp admin pages basic auth, in form of [user, pass], use empty string ["", ""] to disable auth. default: ["admin", "admin"] webapp.static // Webapp static files (htmls/css/js) path, default: "static/dist" webapp.privateDocUrl // Webapp private documentation url, default: "", example: "http://example.com/banshee-manual" alerter.command // Alerter command or script to execute on anomalies found. default: "" alerter.workers // Number of workers to consume command execution jobs. default: 4 alerter.interval // Minimal interval (in seconds) between two alerting message for one metric. default: 1200 alerter.oneDayLimit // Limitation for number of alerting times for one metric in a day. default: 5 alerter.defaultSilentTimeRange // Default silent time range if the project silent is disabled. default: [0, 6] (00:00~06:00)
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 int = 100 // Default period for all metrics in seconds. DefaultPeriod uint32 = 1 * Day // Default metric expiration. DefaultExpiration uint32 = 7 * Day // Default weight factor for moving average. DefaultTrendingFactor float64 = 0.1 // 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 alert times limit in one day for the same metric DefaultAlerterOneDayLimit uint32 = 5 // 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" )
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 at least 1 hour") ErrExpiration = errors.New("expiration should be an integer greater than 5 * period") ErrExpirationDivPeriodClean = errors.New("expiration should be divided by period cleanly") ErrDetectorPort = errors.New("invalid detector.port") ErrDetectorTrendingFactor = errors.New("detector.trendingFactor should be a float between 0 and 1") ErrDetectorFilterOffset = errors.New("detector.filterOffset should be a float between 0 and 1") ErrDetectorFilterTimes = errors.New("detector.filterTimes should be smaller") ErrDetectorDefaultThresholdMaxsLen = errors.New("detector.defaultThresholdMaxs should have up to 8 items") ErrDetectorDefaultThresholdMinsLen = errors.New("detector.defaultThresholdMins should have up to 8 items") ErrDetectorDefaultThresholdMaxZero = errors.New("detector.defaultThresholdMaxs should not contain zeros") ErrDetectorDefaultThresholdMinZero = errors.New("detector.defaultThresholdMins should not contain zeros") ErrDetectorFillBlankZerosLen = errors.New("detector.fillBlankZeros 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.oneDayLimit should be greater than 0") ErrAlerterDefaultSilentTimeRange = errors.New("alerter.defaultTimeRange 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"` Period uint32 `json:"period"` Expiration uint32 `json:"expiration"` Storage configStorage `json:"storage"` Detector configDetector `json:"detector"` Webapp configWebapp `json:"webapp"` Alerter configAlerter `json:"alerter"` }
Config is the configuration container.
func (*Config) UpdateWithJSONFile ¶
UpdateWithJSONFile update the config from a json file.
Click to show internal directories.
Click to hide internal directories.