mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/pushmetrics: properly handle errors when initializing pushmetrics
This commit is contained in:
parent
4c2f9a1a2e
commit
ad6b3cd47d
7 changed files with 13 additions and 8 deletions
|
@ -36,9 +36,9 @@ func main() {
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
envflag.Parse()
|
envflag.Parse()
|
||||||
pushmetrics.Init()
|
|
||||||
buildinfo.Init()
|
buildinfo.Init()
|
||||||
logger.Init()
|
logger.Init()
|
||||||
|
pushmetrics.Init()
|
||||||
|
|
||||||
if promscrape.IsDryRun() {
|
if promscrape.IsDryRun() {
|
||||||
*dryRun = true
|
*dryRun = true
|
||||||
|
|
|
@ -77,10 +77,10 @@ func main() {
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
envflag.Parse()
|
envflag.Parse()
|
||||||
pushmetrics.Init()
|
|
||||||
remotewrite.InitSecretFlags()
|
remotewrite.InitSecretFlags()
|
||||||
buildinfo.Init()
|
buildinfo.Init()
|
||||||
logger.Init()
|
logger.Init()
|
||||||
|
pushmetrics.Init()
|
||||||
|
|
||||||
if promscrape.IsDryRun() {
|
if promscrape.IsDryRun() {
|
||||||
if err := promscrape.CheckConfig(); err != nil {
|
if err := promscrape.CheckConfig(); err != nil {
|
||||||
|
|
|
@ -80,9 +80,10 @@ func main() {
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
envflag.Parse()
|
envflag.Parse()
|
||||||
pushmetrics.Init()
|
|
||||||
buildinfo.Init()
|
buildinfo.Init()
|
||||||
logger.Init()
|
logger.Init()
|
||||||
|
pushmetrics.Init()
|
||||||
|
|
||||||
err := templates.Load(*ruleTemplatesPath, true)
|
err := templates.Load(*ruleTemplatesPath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatalf("failed to parse %q: %s", *ruleTemplatesPath, err)
|
logger.Fatalf("failed to parse %q: %s", *ruleTemplatesPath, err)
|
||||||
|
|
|
@ -34,9 +34,10 @@ func main() {
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
envflag.Parse()
|
envflag.Parse()
|
||||||
pushmetrics.Init()
|
|
||||||
buildinfo.Init()
|
buildinfo.Init()
|
||||||
logger.Init()
|
logger.Init()
|
||||||
|
pushmetrics.Init()
|
||||||
|
|
||||||
logger.Infof("starting vmauth at %q...", *httpListenAddr)
|
logger.Infof("starting vmauth at %q...", *httpListenAddr)
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
initAuthConfig()
|
initAuthConfig()
|
||||||
|
|
|
@ -42,9 +42,9 @@ func main() {
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
envflag.Parse()
|
envflag.Parse()
|
||||||
pushmetrics.Init()
|
|
||||||
buildinfo.Init()
|
buildinfo.Init()
|
||||||
logger.Init()
|
logger.Init()
|
||||||
|
pushmetrics.Init()
|
||||||
|
|
||||||
if len(*snapshotCreateURL) > 0 {
|
if len(*snapshotCreateURL) > 0 {
|
||||||
if len(*snapshotName) > 0 {
|
if len(*snapshotName) > 0 {
|
||||||
|
|
|
@ -34,9 +34,9 @@ func main() {
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
envflag.Parse()
|
envflag.Parse()
|
||||||
pushmetrics.Init()
|
|
||||||
buildinfo.Init()
|
buildinfo.Init()
|
||||||
logger.Init()
|
logger.Init()
|
||||||
|
pushmetrics.Init()
|
||||||
|
|
||||||
go httpserver.Serve(*httpListenAddr, nil)
|
go httpserver.Serve(*httpListenAddr, nil)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/appmetrics"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/appmetrics"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/flagutil"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/flagutil"
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
"github.com/VictoriaMetrics/metrics"
|
"github.com/VictoriaMetrics/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,10 +24,12 @@ func init() {
|
||||||
flagutil.RegisterSecretFlag("pushmetrics.url")
|
flagutil.RegisterSecretFlag("pushmetrics.url")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init must be called after flag.Parse.
|
// Init must be called after logger.Init
|
||||||
func Init() {
|
func Init() {
|
||||||
extraLabels := strings.Join(*pushExtraLabels, ",")
|
extraLabels := strings.Join(*pushExtraLabels, ",")
|
||||||
for _, pu := range *pushURL {
|
for _, pu := range *pushURL {
|
||||||
_ = metrics.InitPushExt(pu, *pushInterval, extraLabels, appmetrics.WritePrometheusMetrics)
|
if err := metrics.InitPushExt(pu, *pushInterval, extraLabels, appmetrics.WritePrometheusMetrics); err != nil {
|
||||||
|
logger.Fatalf("cannot initialize pushmetrics: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue