categraf/agent/prometheus_scrape.go

30 lines
646 B
Go
Raw Normal View History

package agent
import (
2022-07-12 12:57:03 +08:00
"log"
2022-07-12 12:57:03 +08:00
coreconfig "flashcat.cloud/categraf/config"
"flashcat.cloud/categraf/prometheus"
)
func (a *Agent) startPrometheusScrape() {
if coreconfig.Config == nil ||
2022-07-13 11:43:03 +08:00
coreconfig.Config.Prometheus == nil ||
!coreconfig.Config.Prometheus.Enable {
log.Println("I! prometheus scraping disabled!")
return
}
go prometheus.Start()
log.Println("I! prometheus scraping started!")
}
func (a *Agent) stopPrometheusScrape() {
if coreconfig.Config == nil ||
2022-07-13 11:43:03 +08:00
coreconfig.Config.Prometheus == nil ||
!coreconfig.Config.Prometheus.Enable {
return
}
prometheus.Stop()
2022-07-12 12:57:03 +08:00
log.Println("I! prometheus scraping stopped!")
}