-
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
[WIP]: 34125 output name issue #34143
Changes from all commits
2124550
6b8add5
c8c415a
821741b
58b94b0
582d51a
9de3e57
7140644
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,10 +55,9 @@ import ( | |
_ "github.com/elastic/beats/v7/filebeat/autodiscover" | ||
) | ||
|
||
const pipelinesWarning = "Filebeat is unable to load the ingest pipelines for the configured" + | ||
" modules because the Elasticsearch output is not configured/enabled. If you have" + | ||
" already loaded the ingest pipelines or are using Logstash pipelines, you" + | ||
" can ignore this warning." | ||
const pipelinesWarning = "ingest pipelines disabled as configured/enabled output is %q. " + | ||
"Only Elasticsearch output supports them. If you have already loaded the " + | ||
"ingest pipelines or are using Logstash pipelines, you can ignore this warning." | ||
|
||
var once = flag.Bool("once", false, "Run filebeat only once until all harvesters reach EOF") | ||
|
||
|
@@ -161,7 +160,8 @@ func newBeater(b *beat.Beat, plugins PluginFactory, rawConfig *conf.C) (beat.Bea | |
// setupPipelineLoaderCallback sets the callback function for loading pipelines during setup. | ||
func (fb *Filebeat) setupPipelineLoaderCallback(b *beat.Beat) error { | ||
if b.Config.Output.Name() != "elasticsearch" { | ||
logp.Warn(pipelinesWarning) | ||
logp.Info(fmt.Sprintf(pipelinesWarning, b.Config.Output.Name())) | ||
logp.Info("b.Config.Output keys: %v", b.Config.Output.Config().FlattenedKeys()) | ||
return nil | ||
} | ||
|
||
|
@@ -173,15 +173,15 @@ func (fb *Filebeat) setupPipelineLoaderCallback(b *beat.Beat) error { | |
} | ||
|
||
// When running the subcommand setup, configuration from modules.d directories | ||
// have to be loaded using cfg.Reloader. Otherwise those configurations are skipped. | ||
// have to be loaded using cfg.Reloader. Otherwise, those configurations are skipped. | ||
pipelineLoaderFactory := newPipelineLoaderFactory(b.Config.Output.Config()) | ||
enableAllFilesets, _ := b.BeatConfig.Bool("config.modules.enable_all_filesets", -1) | ||
modulesFactory := fileset.NewSetupFactory(b.Info, pipelineLoaderFactory, enableAllFilesets) | ||
if fb.config.ConfigModules.Enabled() { | ||
if enableAllFilesets { | ||
//All module configs need to be loaded to enable all the filesets | ||
//contained in the modules. The default glob just loads the enabled | ||
//ones. Switching the glob pattern from *.yml to * achieves this. | ||
// All module configs need to be loaded to enable all the filesets | ||
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. FYI we explicitly disable modules (and filesets) when running under agent: https:/elastic/elastic-agent/blob/7f7faf365aeb303c6e4bb557f3f4b7f4de4025e7/specs/filebeat.spec.yml#L41 This functionality is replaced with integrations. |
||
// contained in the modules. The default glob just loads the enabled | ||
// ones. Switching the glob pattern from *.yml to * achieves this. | ||
origPath, _ := fb.config.ConfigModules.String("path", -1) | ||
newPath := strings.TrimSuffix(origPath, ".yml") | ||
_ = fb.config.ConfigModules.SetString("path", -1, newPath) | ||
|
@@ -199,7 +199,8 @@ func (fb *Filebeat) setupPipelineLoaderCallback(b *beat.Beat) error { | |
// setup. | ||
func (fb *Filebeat) loadModulesPipelines(b *beat.Beat) error { | ||
if b.Config.Output.Name() != "elasticsearch" { | ||
logp.Warn(pipelinesWarning) | ||
logp.Info(fmt.Sprintf(pipelinesWarning, b.Config.Output.Name())) | ||
logp.Info("b.Config.Output keys: %v", b.Config.Output.Config().FlattenedKeys()) | ||
return nil | ||
} | ||
|
||
|
@@ -287,7 +288,8 @@ func (fb *Filebeat) Run(b *beat.Beat) error { | |
if b.Config.Output.Name() == "elasticsearch" { | ||
pipelineLoaderFactory = newPipelineLoaderFactory(b.Config.Output.Config()) | ||
} else { | ||
logp.Warn(pipelinesWarning) | ||
logp.Info(fmt.Sprintf(pipelinesWarning, b.Config.Output.Name())) | ||
logp.Info("b.Config.Output keys: %v", b.Config.Output.Config().FlattenedKeys()) | ||
} | ||
|
||
inputsLogger := logp.NewLogger("input") | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -39,9 +39,9 @@ type Creator func(*Beat, *config.C) (Beater, error) | |||
// | ||||
// The Stop() method is invoked the first time (and only the first time) a | ||||
// shutdown signal is received. The Stop()-method normally will stop the Run()-loop, | ||||
// such that the beat can gracefully shutdown. | ||||
// such that the beat can gracefully shut down. | ||||
type Beater interface { | ||||
// The main event loop. This method should block until signalled to stop by an | ||||
// Run runs the main event loop. This method should block until signalled to stop by an | ||||
// invocation of the Stop() method. | ||||
Run(b *Beat) error | ||||
|
||||
|
@@ -84,7 +84,7 @@ type Beat struct { | |||
// BeatConfig struct contains the basic configuration of every beat | ||||
type BeatConfig struct { | ||||
// output/publishing related configurations | ||||
Output config.Namespace `config:"output"` | ||||
Output config.Namespace `config:"outputs"` // this seems to be the issue. But right now it seems that somehow it works when loading the config, but later on Output is empty again | ||||
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. This was also the source of the problem in elastic/elastic-agent#1860 (comment) The Beats assume they are reading a complete configuration file at startup to populate that. This is not true for the V2 agent. There is no output configured at startup. In V1 we actually did read the reference Filebeat configuration at startup, and this worked by coincidence because the default output is Elasticsearch. Ideally what we do in V2 is correct, don't assume an output until the agent configures it. This avoids problems where the Beat loads something from the reference config that conflicts with what the agent sent it, or problems where the user notices the Beats are reaching out to localhost:9200 at startup when a Logstash output is configured. The problem is the Beats were written assuming they could read a valid config file at startup, so this is causing some weird problems in code that assumes this is populated when it isn't necessarily. The original issue for this change was #31901 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. This is where a blank default configuration is created: beats/libbeat/cfgfile/cfgfile.go Line 166 in d8204a2
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. If the problem is that the ingest pipeline setup is being skipped, that should not actually be the cause of this problem. See https:/elastic/beats/pull/34143/files#r1059158293 |
||||
} | ||||
|
||||
// OverwritePipelinesCallback can be used by the Beat to register Ingest pipeline loader | ||||
|
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.
Ingest pipelines (that run on Elasticsearch) are handled by integration packages for agent. For standalone Filebeat it can load them itself, but the agent doesn't use the functionality.
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.
https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html#pipelines-for-fleet-elastic-agent for how this works under agent.
This entire section should be getting bypassed.