diff --git a/x-pack/elastic-agent/pkg/agent/operation/operator.go b/x-pack/elastic-agent/pkg/agent/operation/operator.go index 63f1d3045668..d4bfa33e6ae1 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/operator.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operator.go @@ -24,6 +24,7 @@ import ( "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/app" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/monitoring/noop" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/service" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/server" @@ -293,6 +294,13 @@ func (o *Operator) getApp(p Descriptor) (Application, error) { // TODO: (michal) join args into more compact options version var a Application var err error + + monitor := o.monitor + if app.IsSidecar(p) { + // make watchers unmonitorable + monitor = noop.NewMonitor() + } + if p.ServicePort() == 0 { // Applications without service ports defined are ran as through the process application type. a, err = process.NewApplication( @@ -306,7 +314,7 @@ func (o *Operator) getApp(p Descriptor) (Application, error) { o.config, o.logger, o.reporter, - o.monitor, + monitor, o.statusController) } else { // Service port is defined application is ran with service application type, with it fetching @@ -323,7 +331,7 @@ func (o *Operator) getApp(p Descriptor) (Application, error) { o.config, o.logger, o.reporter, - o.monitor, + monitor, o.statusController) }