add default value for some parameters
This commit is contained in:
parent
027cf18f99
commit
e083821da3
|
@ -2,3 +2,8 @@
|
||||||
enable=true
|
enable=true
|
||||||
scrape_config_file="/path/to/scrape.yaml"
|
scrape_config_file="/path/to/scrape.yaml"
|
||||||
web_address="127.0.0.1:9091"
|
web_address="127.0.0.1:9091"
|
||||||
|
##wal file storage path ,default ./data-agent
|
||||||
|
# wal_storage_path="/path/to/storage"
|
||||||
|
##wal reserve time duration, default value is 2 hour
|
||||||
|
# wal_min_duration=2
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,7 @@ type (
|
||||||
Enable bool `toml:"enable"`
|
Enable bool `toml:"enable"`
|
||||||
ScrapeConfigFile string `toml:"scrape_config_file"`
|
ScrapeConfigFile string `toml:"scrape_config_file"`
|
||||||
WebAddress string `toml:"web_address"`
|
WebAddress string `toml:"web_address"`
|
||||||
|
StoragePath string `toml:"wal_storage_path"`
|
||||||
|
MinBlockDuration string `toml:"wal_min_duration"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -495,16 +495,20 @@ func Start() {
|
||||||
discoveryManagerScrape := discovery.NewManager(ctxScrape, log.With(logger, "component", "discovery manager scrape"), discovery.Name("scrape"))
|
discoveryManagerScrape := discovery.NewManager(ctxScrape, log.With(logger, "component", "discovery manager scrape"), discovery.Name("scrape"))
|
||||||
discoveryManagerNotify := discovery.NewManager(ctxNotify, log.With(logger, "component", "discovery manager notify"), discovery.Name("notify"))
|
discoveryManagerNotify := discovery.NewManager(ctxNotify, log.With(logger, "component", "discovery manager notify"), discovery.Name("notify"))
|
||||||
|
|
||||||
// TODO scrapeopts configurable
|
|
||||||
if cfg.scrape.ExtraMetrics {
|
if cfg.scrape.ExtraMetrics {
|
||||||
|
// Experimental additional scrape metrics
|
||||||
|
// TODO scrapeopts configurable
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage := &readyStorage{stats: tsdb.NewDBStats()}
|
localStorage := &readyStorage{stats: tsdb.NewDBStats()}
|
||||||
|
|
||||||
// TODO agentStoragePath configurable
|
cfg.agentStoragePath = coreconfig.Config.Prometheus.StoragePath
|
||||||
if len(cfg.agentStoragePath) == 0 {
|
if len(cfg.agentStoragePath) == 0 {
|
||||||
cfg.agentStoragePath = "./data-agent"
|
cfg.agentStoragePath = "./data-agent"
|
||||||
}
|
}
|
||||||
|
if cfg.tsdb.MinBlockDuration == model.Duration(0) {
|
||||||
|
cfg.tsdb.MinBlockDuration = model.Duration(2 * time.Hour)
|
||||||
|
}
|
||||||
if cfg.webTimeout == model.Duration(0) {
|
if cfg.webTimeout == model.Duration(0) {
|
||||||
cfg.webTimeout = model.Duration(time.Minute * 5)
|
cfg.webTimeout = model.Duration(time.Minute * 5)
|
||||||
}
|
}
|
||||||
|
@ -530,7 +534,6 @@ func Start() {
|
||||||
|
|
||||||
scraper := &readyScrapeManager{}
|
scraper := &readyScrapeManager{}
|
||||||
|
|
||||||
// TODO configurable
|
|
||||||
remoteFlushDeadline := time.Duration(1 * time.Minute)
|
remoteFlushDeadline := time.Duration(1 * time.Minute)
|
||||||
localStoragePath := cfg.agentStoragePath
|
localStoragePath := cfg.agentStoragePath
|
||||||
remoteStorage := remote.NewStorage(log.With(logger, "component", "remote"), prometheus.DefaultRegisterer, localStorage.StartTime, localStoragePath, time.Duration(remoteFlushDeadline), scraper)
|
remoteStorage := remote.NewStorage(log.With(logger, "component", "remote"), prometheus.DefaultRegisterer, localStorage.StartTime, localStoragePath, time.Duration(remoteFlushDeadline), scraper)
|
||||||
|
@ -634,15 +637,18 @@ func Start() {
|
||||||
{
|
{
|
||||||
// Termination handler.
|
// Termination handler.
|
||||||
term := make(chan os.Signal, 1)
|
term := make(chan os.Signal, 1)
|
||||||
signal.Notify(term, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(term, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGPIPE)
|
||||||
cancel := make(chan struct{})
|
cancel := make(chan struct{})
|
||||||
g.Add(
|
g.Add(
|
||||||
func() error {
|
func() error {
|
||||||
// Don't forget to release the reloadReady channel so that waiting blocks can exit normally.
|
// Don't forget to release the reloadReady channel so that waiting blocks can exit normally.
|
||||||
select {
|
select {
|
||||||
case <-term:
|
case sig := <-term:
|
||||||
level.Warn(logger).Log("msg", "Received SIGTERM, exiting gracefully...")
|
level.Warn(logger).Log("msg", "Received ", sig.String())
|
||||||
reloadReady.Close()
|
if sig != syscall.SIGPIPE {
|
||||||
|
level.Warn(logger).Log("msg", "exiting gracefully...")
|
||||||
|
reloadReady.Close()
|
||||||
|
}
|
||||||
case <-webHandler.Quit():
|
case <-webHandler.Quit():
|
||||||
level.Warn(logger).Log("msg", "Received termination request via web service, exiting gracefully...")
|
level.Warn(logger).Log("msg", "Received termination request via web service, exiting gracefully...")
|
||||||
case <-cancel:
|
case <-cancel:
|
||||||
|
|
Loading…
Reference in New Issue