From e083821da31b633ea0884753a6423554e32031c3 Mon Sep 17 00:00:00 2001 From: kongfei Date: Tue, 12 Jul 2022 08:51:02 +0800 Subject: [PATCH] add default value for some parameters --- conf/prometheus.toml | 5 +++++ config/prometheus.go | 2 ++ prometheus/prometheus.go | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/conf/prometheus.toml b/conf/prometheus.toml index 12848d6..9251293 100644 --- a/conf/prometheus.toml +++ b/conf/prometheus.toml @@ -2,3 +2,8 @@ enable=true scrape_config_file="/path/to/scrape.yaml" 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 + diff --git a/config/prometheus.go b/config/prometheus.go index c2a518a..64f7315 100644 --- a/config/prometheus.go +++ b/config/prometheus.go @@ -5,5 +5,7 @@ type ( Enable bool `toml:"enable"` ScrapeConfigFile string `toml:"scrape_config_file"` WebAddress string `toml:"web_address"` + StoragePath string `toml:"wal_storage_path"` + MinBlockDuration string `toml:"wal_min_duration"` } ) diff --git a/prometheus/prometheus.go b/prometheus/prometheus.go index 1816644..51358f3 100644 --- a/prometheus/prometheus.go +++ b/prometheus/prometheus.go @@ -495,16 +495,20 @@ func Start() { 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")) - // TODO scrapeopts configurable if cfg.scrape.ExtraMetrics { + // Experimental additional scrape metrics + // TODO scrapeopts configurable } localStorage := &readyStorage{stats: tsdb.NewDBStats()} - // TODO agentStoragePath configurable + cfg.agentStoragePath = coreconfig.Config.Prometheus.StoragePath if len(cfg.agentStoragePath) == 0 { 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) { cfg.webTimeout = model.Duration(time.Minute * 5) } @@ -530,7 +534,6 @@ func Start() { scraper := &readyScrapeManager{} - // TODO configurable remoteFlushDeadline := time.Duration(1 * time.Minute) localStoragePath := cfg.agentStoragePath 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. 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{}) g.Add( func() error { // Don't forget to release the reloadReady channel so that waiting blocks can exit normally. select { - case <-term: - level.Warn(logger).Log("msg", "Received SIGTERM, exiting gracefully...") - reloadReady.Close() + case sig := <-term: + level.Warn(logger).Log("msg", "Received ", sig.String()) + if sig != syscall.SIGPIPE { + level.Warn(logger).Log("msg", "exiting gracefully...") + reloadReady.Close() + } case <-webHandler.Quit(): level.Warn(logger).Log("msg", "Received termination request via web service, exiting gracefully...") case <-cancel: