set default value for log level and web address

This commit is contained in:
kongfei 2022-07-12 11:54:46 +08:00
parent e083821da3
commit 072649941e
3 changed files with 15 additions and 8 deletions

View File

@ -1,8 +1,8 @@
global:
scrape_interval: 15s
external_labels:
cluster: test
replica: 0
#external_labels:
# cluster: test
# replica: 0
scrape_configs:
- job_name: "categraf-scrape-metrics"

View File

@ -1,7 +1,6 @@
[prometheus]
enable=true
scrape_config_file="/path/to/scrape.yaml"
web_address="127.0.0.1:9091"
scrape_config_file="/path/to/in_cluster_scrape.yaml"
##wal file storage path ,default ./data-agent
# wal_storage_path="/path/to/storage"
##wal reserve time duration, default value is 2 hour

View File

@ -478,7 +478,15 @@ func Start() {
Registerer: prometheus.DefaultRegisterer,
Gatherer: prometheus.DefaultGatherer,
},
promlogConfig: promlog.Config{},
promlogConfig: promlog.Config{
Level: &promlog.AllowedLevel{},
},
}
if coreconfig.Config.DebugMode || coreconfig.Config.TestMode {
cfg.promlogConfig.Level.Set("debug")
} else {
cfg.promlogConfig.Level.Set("info")
}
logger := promlog.New(&cfg.promlogConfig)
@ -544,7 +552,7 @@ func Start() {
cfg.web.ListenAddress = coreconfig.Config.Prometheus.WebAddress
if len(cfg.web.ListenAddress) == 0 {
cfg.web.ListenAddress = "127.0.0.1:9091"
cfg.web.ListenAddress = "127.0.0.1:0"
}
cfg.web.ExternalURL, err = computeExternalURL(cfg.prometheusURL, cfg.web.ListenAddress)
@ -644,7 +652,7 @@ func Start() {
// Don't forget to release the reloadReady channel so that waiting blocks can exit normally.
select {
case sig := <-term:
level.Warn(logger).Log("msg", "Received ", sig.String())
level.Warn(logger).Log("msg", "Received "+sig.String())
if sig != syscall.SIGPIPE {
level.Warn(logger).Log("msg", "exiting gracefully...")
reloadReady.Close()