diff --git a/pkg/router/template/router.go b/pkg/router/template/router.go index 0ccd22fd1..a65a57f21 100644 --- a/pkg/router/template/router.go +++ b/pkg/router/template/router.go @@ -98,6 +98,8 @@ type templateRouter struct { stateChanged bool // metricReload tracks reloads metricReload prometheus.Summary + // metricReloadFails tracks reload failures + metricReloadFails prometheus.Counter // metricWriteConfig tracks writing config metricWriteConfig prometheus.Summary // dynamicConfigManager configures route changes dynamically on the @@ -178,6 +180,12 @@ func newTemplateRouter(cfg templateRouterCfg) (*templateRouter, error) { Help: "Measures the time spent reloading the router in seconds.", }) prometheus.MustRegister(metricsReload) + metricReloadFails := prometheus.NewCounter(prometheus.CounterOpts{ + Namespace: "template_router", + Name: "reload_fails", + Help: "Tracks the number of failed router reloads", + }) + prometheus.MustRegister(metricReloadFails) metricWriteConfig := prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: "template_router", Name: "write_config_seconds", @@ -207,6 +215,7 @@ func newTemplateRouter(cfg templateRouterCfg) (*templateRouter, error) { dynamicConfigManager: cfg.dynamicConfigManager, metricReload: metricsReload, + metricReloadFails: metricReloadFails, metricWriteConfig: metricWriteConfig, rateLimitedCommitFunction: nil, @@ -221,10 +230,7 @@ func newTemplateRouter(cfg templateRouterCfg) (*templateRouter, error) { log.V(0).Info("initializing dynamic config manager ... ") router.dynamicConfigManager.Initialize(router, router.defaultCertificatePath) } - log.V(4).Info("committing state") - // Bypass the rate limiter to ensure the first sync will be - // committed without delay. - router.commitAndReload() + return router, nil } @@ -434,6 +440,8 @@ func (r *templateRouter) commitAndReload() error { if r.dynamicConfigManager != nil { r.dynamicConfigManager.Notify(RouterEventReloadError) } + // Increment the failed reload counter when a reload fails + r.metricReloadFails.Inc() return err }