support log level for prometheus

This commit is contained in:
kongfei 2022-07-12 12:57:03 +08:00
parent 1ec707fc9b
commit d70960cb5b
4 changed files with 11 additions and 1 deletions

View File

@ -1,8 +1,9 @@
package agent
import (
coreconfig "flashcat.cloud/categraf/config"
"log"
coreconfig "flashcat.cloud/categraf/config"
"flashcat.cloud/categraf/prometheus"
)
@ -11,6 +12,7 @@ func (a *Agent) startPrometheusScrape() {
!coreconfig.Config.Prometheus.Enable {
return
}
log.Println("I! prometheus scraping started!")
go prometheus.Start()
}
@ -20,4 +22,5 @@ func (a *Agent) stopPrometheusScrape() {
return
}
prometheus.Stop()
log.Println("I! prometheus scraping stopped!")
}

View File

@ -1,6 +1,8 @@
[prometheus]
enable=true
scrape_config_file="/path/to/in_cluster_scrape.yaml"
## log level, debug warn info error
log_level="info"
##wal file storage path ,default ./data-agent
# wal_storage_path="/path/to/storage"
##wal reserve time duration, default value is 2 hour

View File

@ -3,6 +3,7 @@ package config
type (
Prometheus struct {
Enable bool `toml:"enable"`
LogLevel string `toml:"log_level"`
ScrapeConfigFile string `toml:"scrape_config_file"`
WebAddress string `toml:"web_address"`
StoragePath string `toml:"wal_storage_path"`

View File

@ -486,6 +486,10 @@ func Start() {
if coreconfig.Config.DebugMode || coreconfig.Config.TestMode {
cfg.promlogConfig.Level.Set("debug")
} else {
cfg.promlogConfig.Level.Set(coreconfig.Config.Prometheus.LogLevel)
}
if cfg.promlogConfig.Level.String() == "" {
cfg.promlogConfig.Level.Set("info")
}