-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[libbeat | filebeat] Log error when parsing config block and disabled input on filebeat #30534
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3e9f4df
log error and disabled input on filebeat
AndersonQ 61cb76c
changelog
AndersonQ 272303c
Update filebeat/input/log/harvester.go
AndersonQ 1876918
pr changes
AndersonQ 6c92a39
more logs
AndersonQ 9a408e2
.
AndersonQ 904801b
Merge branch 'main' into filebeat-improve-logs
AndersonQ cd9a4f8
a test
AndersonQ 3c88ab6
.
AndersonQ 3fdfa7c
fix test
AndersonQ 0b369bc
add an optional error message for 'wait_until'
AndersonQ 8b2aaec
Merge branch 'main' into filebeat-improve-logs
AndersonQ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,30 +68,28 @@ func (c *crawler) Start( | |
) error { | ||
log := c.log | ||
|
||
log.Infof("Loading Inputs: %v", len(c.inputConfigs)) | ||
log.Infof("Loading Inputs: %d", len(c.inputConfigs)) | ||
|
||
// Prospect the globs/paths given on the command line and launch harvesters | ||
for _, inputConfig := range c.inputConfigs { | ||
err := c.startInput(pipeline, inputConfig) | ||
if err != nil { | ||
return fmt.Errorf("starting input failed: %+v", err) | ||
return fmt.Errorf("starting input failed: %w", err) | ||
} | ||
} | ||
|
||
if configInputs.Enabled() { | ||
c.inputReloader = cfgfile.NewReloader(pipeline, configInputs) | ||
if err := c.inputReloader.Check(c.inputsFactory); err != nil { | ||
return fmt.Errorf("creating input reloader failed: %+v", err) | ||
return fmt.Errorf("creating input reloader failed: %w", err) | ||
} | ||
|
||
} | ||
|
||
if configModules.Enabled() { | ||
c.modulesReloader = cfgfile.NewReloader(pipeline, configModules) | ||
if err := c.modulesReloader.Check(c.modulesFactory); err != nil { | ||
return fmt.Errorf("creating module reloader failed: %+v", err) | ||
return fmt.Errorf("creating module reloader failed: %w", err) | ||
} | ||
|
||
} | ||
|
||
if c.inputReloader != nil { | ||
|
@@ -105,7 +103,7 @@ func (c *crawler) Start( | |
}() | ||
} | ||
|
||
log.Infof("Loading and starting Inputs completed. Enabled inputs: %v", len(c.inputs)) | ||
log.Infof("Loading and starting Inputs completed. Enabled inputs: %d", len(c.inputs)) | ||
|
||
return nil | ||
} | ||
|
@@ -114,23 +112,32 @@ func (c *crawler) startInput( | |
pipeline beat.PipelineConnector, | ||
config *common.Config, | ||
) error { | ||
// TODO: Either use debug or remove it after https://github.com/elastic/beats/pull/30534 | ||
// is fixed. | ||
c.log.Infof("starting input, keys present on the config: %v", | ||
config.FlattenedKeys()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ for not leaking senstitive information. |
||
|
||
if !config.Enabled() { | ||
c.log.Infof("input disabled, skipping it") | ||
return nil | ||
} | ||
|
||
var h map[string]interface{} | ||
config.Unpack(&h) | ||
err := config.Unpack(&h) | ||
if err != nil { | ||
return fmt.Errorf("could not unpack config: %w", err) | ||
} | ||
id, err := hashstructure.Hash(h, nil) | ||
if err != nil { | ||
return fmt.Errorf("can not compute id from configuration: %v", err) | ||
return fmt.Errorf("can not compute id from configuration: %w", err) | ||
} | ||
if _, ok := c.inputs[id]; ok { | ||
return fmt.Errorf("input with same ID already exists: %v", id) | ||
return fmt.Errorf("input with same ID already exists: %d", id) | ||
} | ||
|
||
runner, err := c.inputsFactory.Create(pipeline, config) | ||
if err != nil { | ||
return fmt.Errorf("error while initializing input: %v", err) | ||
return fmt.Errorf("error while initializing input: %w", err) | ||
} | ||
if inputRunner, ok := runner.(*input.Runner); ok { | ||
inputRunner.Once = c.once | ||
|
@@ -155,7 +162,7 @@ func (c *crawler) Stop() { | |
}() | ||
} | ||
|
||
logp.Info("Stopping %v inputs", len(c.inputs)) | ||
logp.Info("Stopping %d inputs", len(c.inputs)) | ||
// Stop inputs in parallel | ||
for id, p := range c.inputs { | ||
id, p := id, p | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,7 @@ func (cm *Manager) OnConfig(s string) { | |
if errs := cm.apply(blocks); errs != nil { | ||
// `cm.apply` already logs the errors; currently allow beat to run degraded | ||
cm.updateStatusWithError(err) | ||
cm.logger.Errorf("failed applying config blocks: %v", err) | ||
return | ||
} | ||
|
||
|
@@ -256,8 +257,8 @@ func (cm *Manager) apply(blocks ConfigBlocks) error { | |
} | ||
|
||
// Unset missing configs | ||
for name := range missing { | ||
if missing[name] { | ||
for name, isMissing := range missing { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 nice change. |
||
if isMissing { | ||
if err := cm.reload(name, []*ConfigBlock{}); err != nil { | ||
errors = multierror.Append(errors, err) | ||
} | ||
|
@@ -319,6 +320,7 @@ func (cm *Manager) toConfigBlocks(cfg common.MapStr) (ConfigBlocks, error) { | |
for _, regName := range cm.registry.GetRegisteredNames() { | ||
iBlock, err := cfg.GetValue(regName) | ||
if err != nil { | ||
cm.logger.Errorf("failed to get '%s' from config: %v. Continuing to next one", regName, err) | ||
continue | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndersonQ The len() is a good start but let's be more precise like having a detailed count for each input. IE.
Filestream input: 2
, same comment for this log statement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm logging the input config keys now on
startInput
now.The
inputs
field doesn't have much information to log, it's an implementation ofRunner
:/