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

fix direct agent configuration #5380

Merged
merged 10 commits into from
Jun 3, 2021
2 changes: 1 addition & 1 deletion agentcfg/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type Fetcher interface {

// NewFetcher returns a new Fetcher based on the provided config.
func NewFetcher(cfg *config.Config) Fetcher {
if cfg.AgentConfigs != nil {
if cfg.AgentConfigs != nil || !cfg.Kibana.Enabled {
// Direct agent configuration is present, disable communication
// with kibana.
return NewDirectFetcher(cfg.AgentConfigs)
Expand Down
5 changes: 5 additions & 0 deletions beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ func newServerRunner(ctx context.Context, args serverRunnerParams) (*serverRunne
if cfg.DataStreams.Enabled && args.KibanaConfig != nil {
cfg.Kibana.ClientConfig = *args.KibanaConfig
}
if args.Beat.Manager != nil && args.Beat.Manager.Enabled() {
// If we're running in managed mode we do not want to
// communicate with kibana.
cfg.Kibana.Enabled = false
}

runServerContext, cancel := context.WithCancel(ctx)
return &serverRunner{
Expand Down
8 changes: 0 additions & 8 deletions beater/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const (
)

var (
errInvalidAgentConfigServiceName = errors.New("agent_config: either service.name or service.environment must be set")
errInvalidAgentConfigMissingConfig = errors.New("agent_config: no config set")
)

Expand Down Expand Up @@ -113,9 +112,6 @@ type AgentConfig struct {
}

func (s *AgentConfig) setup() error {
if !s.Service.isValid() {
return errInvalidAgentConfigServiceName
}
if s.Config == nil {
return errInvalidAgentConfigMissingConfig
}
Expand Down Expand Up @@ -148,10 +144,6 @@ func (s *Service) String() string {
return strings.Join([]string{name, env}, " ")
}

func (s *Service) isValid() bool {
return s.Name != "" || s.Environment != ""
}

// ExpvarConfig holds config information about exposing expvar
type ExpvarConfig struct {
Enabled *bool `config:"enabled"`
Expand Down