fix: move "Starting Telegraf" log (#10528)
This commit is contained in:
parent
ac65eb6325
commit
8fefb21975
|
|
@ -198,8 +198,6 @@ func runAgent(ctx context.Context,
|
||||||
inputFilters []string,
|
inputFilters []string,
|
||||||
outputFilters []string,
|
outputFilters []string,
|
||||||
) error {
|
) error {
|
||||||
log.Printf("I! Starting Telegraf %s", version)
|
|
||||||
|
|
||||||
// If no other options are specified, load the config file and run.
|
// If no other options are specified, load the config file and run.
|
||||||
c := config.NewConfig()
|
c := config.NewConfig()
|
||||||
c.OutputFilters = outputFilters
|
c.OutputFilters = outputFilters
|
||||||
|
|
@ -241,26 +239,22 @@ func runAgent(ctx context.Context,
|
||||||
return fmt.Errorf("Agent flush_interval must be positive; found %v", c.Agent.Interval)
|
return fmt.Errorf("Agent flush_interval must be positive; found %v", c.Agent.Interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
ag, err := agent.NewAgent(c)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup logging as configured.
|
// Setup logging as configured.
|
||||||
telegraf.Debug = ag.Config.Agent.Debug || *fDebug
|
telegraf.Debug = c.Agent.Debug || *fDebug
|
||||||
logConfig := logger.LogConfig{
|
logConfig := logger.LogConfig{
|
||||||
Debug: telegraf.Debug,
|
Debug: telegraf.Debug,
|
||||||
Quiet: ag.Config.Agent.Quiet || *fQuiet,
|
Quiet: c.Agent.Quiet || *fQuiet,
|
||||||
LogTarget: ag.Config.Agent.LogTarget,
|
LogTarget: c.Agent.LogTarget,
|
||||||
Logfile: ag.Config.Agent.Logfile,
|
Logfile: c.Agent.Logfile,
|
||||||
RotationInterval: ag.Config.Agent.LogfileRotationInterval,
|
RotationInterval: c.Agent.LogfileRotationInterval,
|
||||||
RotationMaxSize: ag.Config.Agent.LogfileRotationMaxSize,
|
RotationMaxSize: c.Agent.LogfileRotationMaxSize,
|
||||||
RotationMaxArchives: ag.Config.Agent.LogfileRotationMaxArchives,
|
RotationMaxArchives: c.Agent.LogfileRotationMaxArchives,
|
||||||
LogWithTimezone: ag.Config.Agent.LogWithTimezone,
|
LogWithTimezone: c.Agent.LogWithTimezone,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.SetupLogging(logConfig)
|
logger.SetupLogging(logConfig)
|
||||||
|
|
||||||
|
log.Printf("I! Starting Telegraf %s", version)
|
||||||
log.Printf("I! Loaded inputs: %s", strings.Join(c.InputNames(), " "))
|
log.Printf("I! Loaded inputs: %s", strings.Join(c.InputNames(), " "))
|
||||||
log.Printf("I! Loaded aggregators: %s", strings.Join(c.AggregatorNames(), " "))
|
log.Printf("I! Loaded aggregators: %s", strings.Join(c.AggregatorNames(), " "))
|
||||||
log.Printf("I! Loaded processors: %s", strings.Join(c.ProcessorNames(), " "))
|
log.Printf("I! Loaded processors: %s", strings.Join(c.ProcessorNames(), " "))
|
||||||
|
|
@ -284,6 +278,11 @@ func runAgent(ctx context.Context,
|
||||||
log.Printf("W! Deprecated outputs: %d and %d options", count[0], count[1])
|
log.Printf("W! Deprecated outputs: %d and %d options", count[0], count[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ag, err := agent.NewAgent(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Notify systemd that telegraf is ready
|
// Notify systemd that telegraf is ready
|
||||||
// SdNotify() only tries to notify if the NOTIFY_SOCKET environment is set, so it's safe to call when systemd isn't present.
|
// SdNotify() only tries to notify if the NOTIFY_SOCKET environment is set, so it's safe to call when systemd isn't present.
|
||||||
// Ignore the return values here because they're not valid for platforms that don't use systemd.
|
// Ignore the return values here because they're not valid for platforms that don't use systemd.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue