Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore init fail input option #1

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,23 @@ func (a *Agent) Run(ctx context.Context) error {

// initPlugins runs the Init function on plugins.
func (a *Agent) initPlugins() error {
inputs := make([]*models.RunningInput, 0)
for _, input := range a.Config.Inputs {
// Share the snmp translator setting with plugins that need it.
if tp, ok := input.Input.(snmp.TranslatorPlugin); ok {
tp.SetTranslator(a.Config.Agent.SnmpTranslator)
}
err := input.Init()
if err != nil {
if err != nil && a.Config.Agent.IgnoreErrorInputs {
log.Printf("W! [agent] Ignore initialize error input %s: %v", input.LogName(), err)
continue
} else if err != nil {
return fmt.Errorf("could not initialize input %s: %v",
input.LogName(), err)
}
inputs = append(inputs, input)
}
a.Config.Inputs = inputs
for _, parser := range a.Config.Parsers {
err := parser.Init()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ type AgentConfig struct {
// Pick a timezone to use when logging or type 'local' for local time.
LogWithTimezone string `toml:"log_with_timezone"`

// Ignore Inputs that error to initialize
IgnoreErrorInputs bool `toml:"ignore_error_inputs"`

Hostname string
OmitHostname bool

Expand Down