diff --git a/internal/metrics/cmdopts.go b/internal/metrics/cmdopts.go index 604e234184..d4d03566e9 100644 --- a/internal/metrics/cmdopts.go +++ b/internal/metrics/cmdopts.go @@ -3,7 +3,7 @@ package metrics // CmdOpts specifies metric command-line options type CmdOpts struct { Metrics string `short:"m" long:"metrics" mapstructure:"metrics" description:"File or folder of YAML files with metrics definitions" env:"PW_METRICS"` - NoHelperFunctions bool `long:"no-helper-functions" mapstructure:"no-helper-functions" description:"Ignore metric definitions using helper functions (in form get_smth()) and don't also roll out any helpers automatically" env:"PW_NO_HELPER_FUNCTIONS"` + CreateHelpers bool `long:"create-helpers" mapstructure:"create-helpers" description:"Create helper database objects from metric definitions" env:"PW_CREATE_HELPERS"` DirectOSStats bool `long:"direct-os-stats" mapstructure:"direct-os-stats" description:"Extract OS related psutil statistics not via PL/Python wrappers but directly on host" env:"PW_DIRECT_OS_STATS"` InstanceLevelCacheMaxSeconds int64 `long:"instance-level-cache-max-seconds" mapstructure:"instance-level-cache-max-seconds" description:"Max allowed staleness for instance level metric data shared between DBs of an instance. Affects 'continuous' host types only. Set to 0 to disable" env:"PW_INSTANCE_LEVEL_CACHE_MAX_SECONDS" default:"30"` EmergencyPauseTriggerfile string `long:"emergency-pause-triggerfile" mapstructure:"emergency-pause-triggerfile" description:"When the file exists no metrics will be temporarily fetched / scraped" env:"PW_EMERGENCY_PAUSE_TRIGGERFILE" default:"/tmp/pgwatch-emergency-pause"` diff --git a/internal/reaper/reaper.go b/internal/reaper/reaper.go index b25a2b8fce..32df25a237 100644 --- a/internal/reaper/reaper.go +++ b/internal/reaper/reaper.go @@ -91,12 +91,13 @@ func (r *Reaper) Reap(mainContext context.Context) (err error) { logger. WithField("sources", len(monitoredDbs)). WithField("metrics", len(metricDefinitionMap.MetricDefs)). + WithField("presets", len(metricDefinitionMap.PresetDefs)). Log(func() logrus.Level { if firstLoop && len(monitoredDbs)*len(metricDefinitionMap.MetricDefs) == 0 { return logrus.WarnLevel } return logrus.InfoLevel - }(), "host info refreshed") + }(), "sources and metrics refreshed") firstLoop = false // only used for failing when 1st config reading fails @@ -124,7 +125,7 @@ func (r *Reaper) Reap(mainContext context.Context) (err error) { logger.Errorf("could not start metric gathering due to connection problem: %s", err) continue } - logger.Infof("Connect OK. Version: %s (in recovery: %v)", ver.VersionStr, ver.IsInRecovery) + logger.WithField("source", monitoredDB.Name).Infof("Connect OK. Version: %s (in recovery: %v)", ver.VersionStr, ver.IsInRecovery) if ver.IsInRecovery && monitoredDB.OnlyIfMaster { logger.Infof("not added to monitoring due to 'master only' property") continue @@ -151,14 +152,11 @@ func (r *Reaper) Reap(mainContext context.Context) (err error) { }() } - if monitoredDB.IsPostgresSource() && !ver.IsInRecovery { - if opts.Metrics.NoHelperFunctions { - logger.Infof("[%s] skipping rollout out helper functions due to the --no-helper-functions flag ...", dbUnique) - } else { - logger.Infof("Trying to create helper functions if missing for \"%s\"...", dbUnique) - if err = TryCreateMetricsFetchingHelpers(mainContext, monitoredDB); err != nil { - logger.Warningf("Failed to create helper functions for \"%s\": %w", dbUnique, err) - } + if monitoredDB.IsPostgresSource() && !ver.IsInRecovery && opts.Metrics.CreateHelpers { + ls := logger.WithField("source", dbUnique) + ls.Info("trying to create helper objects if missing") + if err = TryCreateMetricsFetchingHelpers(mainContext, monitoredDB); err != nil { + ls.Warning("failed to create helper functions: %w", err) } } diff --git a/internal/sinks/multiwriter.go b/internal/sinks/multiwriter.go index ce64c136f8..e789c4c1c1 100644 --- a/internal/sinks/multiwriter.go +++ b/internal/sinks/multiwriter.go @@ -51,7 +51,7 @@ func NewMultiWriter(ctx context.Context, opts *CmdOpts, metricDefs *metrics.Metr return nil, err } mw.AddWriter(w) - l.Info(`measurements sink actviated`) + l.Info(`measurements sink activated`) } if len(mw.writers) == 0 {