Skip to content

Commit

Permalink
Allow starting the beat without an output when CM is enabled (elastic…
Browse files Browse the repository at this point in the history
…#8567)

* Allow starting the beat without an output when CM is enabled

Central management will take care of configuring the output, so we
are allowed to start the beat with a nil output
  • Loading branch information
exekias authored Oct 19, 2018
1 parent 78ef120 commit 1012302
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 13 additions & 0 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
cryptRand "crypto/rand"
"encoding/json"
"errors"
"flag"
"fmt"
"math"
Expand Down Expand Up @@ -309,6 +310,17 @@ func (b *Beat) createBeater(bt beat.Creator) (beat.Beater, error) {
}

debugf("Initializing output plugins")
outputEnabled := b.Config.Output.IsSet() && b.Config.Output.Config().Enabled()
if !outputEnabled {
if b.ConfigManager.Enabled() {
logp.Info("Output is configured through Central Management")
} else {
msg := "No outputs are defined. Please define one under the output section."
logp.Info(msg)
return nil, errors.New(msg)
}
}

pipeline, err := pipeline.Load(b.Info,
pipeline.Monitors{
Metrics: reg,
Expand All @@ -317,6 +329,7 @@ func (b *Beat) createBeater(bt beat.Creator) (beat.Beater, error) {
},
b.Config.Pipeline,
b.Config.Output)

if err != nil {
return nil, fmt.Errorf("error initializing publisher: %+v", err)
}
Expand Down
5 changes: 1 addition & 4 deletions libbeat/publisher/pipeline/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package pipeline

import (
"errors"
"flag"
"fmt"

Expand Down Expand Up @@ -127,9 +126,7 @@ func loadOutput(
}

if !outcfg.IsSet() {
msg := "No outputs are defined. Please define one under the output section."
log.Info(msg)
return outputs.Fail(errors.New(msg))
return outputs.Group{}, nil
}

var (
Expand Down

0 comments on commit 1012302

Please sign in to comment.