From 43b5fb08f8dd20a0e2fba74aa4a2025ba9ba7ca9 Mon Sep 17 00:00:00 2001 From: Scott Trent Date: Tue, 16 Apr 2024 14:54:28 +0900 Subject: [PATCH] improve logging Signed-off-by: Scott Trent --- cmd/main.go | 10 ++++++++++ internal/controller/prometheus_manager.go | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 56c4c04..62bc679 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -89,6 +89,16 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) + susqlLog.Info("SusQL configuration values at runtime") + susqlLog.Info("metricsAddr=" + metricsAddr)) + susqlLog.Info("enableLeaderElection=" + strconv.FormatBool(enableLeaderElection)) + susqlLog.Info("probeAddr=" + probeAddr) + susqlLog.Info("keplerPrometheusUrl=" + keplerPrometheusUrl) + susqlLog.Info("keplerMetricName=" + keplerMetricName) + susqlLog.Info("susqlPrometheusMetricsUrl=" + susqlPrometheusMetricsUrl) + susqlLog.Info("susqlPrometheusDatabaseUrl=" + susqlPrometheusDatabaseUrl) + susqlLog.Info("samplingRate=" + samplingRate) + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: metricsAddr, diff --git a/internal/controller/prometheus_manager.go b/internal/controller/prometheus_manager.go index b18577b..f29a3af 100644 --- a/internal/controller/prometheus_manager.go +++ b/internal/controller/prometheus_manager.go @@ -55,7 +55,7 @@ func (r *LabelGroupReconciler) GetMostRecentValue(susqlPrometheusQuery string) ( if err != nil { r.Logger.V(0).Error(err, fmt.Sprintf("[GetMostRecentValue] Couldn't create HTTP client.\n")+ fmt.Sprintf("\tQuery: %s\n", susqlPrometheusQuery)+ - fmt.Sprintf("\tSusQLPrometheusDatabaseUrl: %s", r.SusQLPrometheusDatabaseUrl)) + fmt.Sprintf("\tSusQLPrometheusDatabaseUrl: %s\n", r.SusQLPrometheusDatabaseUrl)) os.Exit(1) } @@ -78,7 +78,7 @@ func (r *LabelGroupReconciler) GetMostRecentValue(susqlPrometheusQuery string) ( if err != nil { r.Logger.V(0).Error(err, fmt.Sprintf("[GetMostRecentValue] Querying Prometheus didn't work.\n")+ fmt.Sprintf("\tQuery: %s\n", queryString)+ - fmt.Sprintf("\tSusQLPrometheusDatabaseUrl: %s", r.SusQLPrometheusDatabaseUrl)) + fmt.Sprintf("\tSusQLPrometheusDatabaseUrl: %s\n", r.SusQLPrometheusDatabaseUrl)) return 0.0, err } @@ -103,7 +103,7 @@ func (r *LabelGroupReconciler) GetMetricValuesForPodNames(metricName string, pod if err != nil { r.Logger.V(0).Error(err, "[GetMetricValuesForPodNames] Couldn't create an HTTP client.\n"+ fmt.Sprintf("\tmetricName: %s\n", metricName)+ - fmt.Sprintf("\tKeplerPrometheusUrl: %s", r.KeplerPrometheusUrl)) + fmt.Sprintf("\tKeplerPrometheusUrl: %s\n", r.KeplerPrometheusUrl)) os.Exit(1) } @@ -125,7 +125,7 @@ func (r *LabelGroupReconciler) GetMetricValuesForPodNames(metricName string, pod r.Logger.V(0).Error(err, "[GetMetricValuesForPodNames] Querying Prometheus didn't work.\n"+ fmt.Sprintf("\tmetricName: %s\n", metricName)+ fmt.Sprintf("\tKeplerPrometheusUrl: %s\n", r.KeplerPrometheusUrl)+ - fmt.Sprintf("\tqueryString: %s", queryString)) + fmt.Sprintf("\tqueryString: %s\n", queryString)) return nil, err }