Don't complain about internal metrics failure on first try
The monitor sometimes starts up faster than the HTTP server can get ready
@@ -50,7 +50,14 @@ func (m *Monitor) Configure(conf *Config) error {
Timeout: 5 * time.Second,
}
+ // Mark the first interval so that errors are suppressed due to the race
+ // between this monitor starting and the internal metrics service getting
+ // initialized
+ firstTime := true
+
utils.RunOnInterval(ctx, func() {
+ defer func() { firstTime = false }()
+
// Derive the url each time since the AgentMeta data can change but
// there is no notification system for it.
host := conf.Host
@@ -72,7 +79,9 @@ func (m *Monitor) Configure(conf *Config) error {
resp, err := client.Get(url)
if err != nil {
+ if !firstTime {
logger.WithError(err).Error("Could not connect to internal metric server")
+ }
return
}
defer resp.Body.Close()
