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

Add enable-setting to all output plugins #1987

Merged
merged 1 commit into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha3...master[Check the HEAD d
*Affecting all Beats*

- Periodically log internal metrics. {pull}1955[1955]
- Add enable-setting to all output modules. {pull}1987[1987]

*Metricbeat*

Expand Down
18 changes: 18 additions & 0 deletions filebeat/filebeat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ filebeat.prospectors:

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Boolean flag to enable or disable the output module.
#enable: true

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (http and 9200)
# In case you specify and additional path, the scheme is required: http://localhost:9200/path
Expand Down Expand Up @@ -396,6 +399,9 @@ output.elasticsearch:

#----------------------------- Logstash output --------------------------------
#output.logstash:
# Boolean flag to enable or disable the output module.
#enable: true

# The Logstash hosts
#hosts: ["localhost:5044"]

Expand Down Expand Up @@ -446,6 +452,9 @@ output.elasticsearch:

#------------------------------- Kafka output ---------------------------------
#output.kafka:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Kafka broker addresses from where to fetch the cluster metadata.
# The cluster metadata contain the actual Kafka brokers events are published
# to.
Expand Down Expand Up @@ -534,6 +543,9 @@ output.elasticsearch:

#------------------------------- Redis output ---------------------------------
#output.redis:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Redis servers to connect to. If load balancing is enabled, the
# events are distributed to the servers in the list. If one server becomes
# unreachable, the events are distributed to the reachable servers only.
Expand Down Expand Up @@ -630,6 +642,9 @@ output.elasticsearch:

#------------------------------- File output ----------------------------------
#output.file:
# Boolean flag to enable or disable the output module.
#enable: true

# Path to the directory where to save the generated files. The option is
# mandatory.
#path: "/tmp/filebeat"
Expand All @@ -651,6 +666,9 @@ output.elasticsearch:

#----------------------------- Console output ---------------------------------
#output.console:
# Boolean flag to enable or disable the output module.
#enable: true

# Pretty print json event
#pretty: false

Expand Down
18 changes: 18 additions & 0 deletions libbeat/_meta/config.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Boolean flag to enable or disable the output module.
#enable: true

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (http and 9200)
# In case you specify and additional path, the scheme is required: http://localhost:9200/path
Expand Down Expand Up @@ -178,6 +181,9 @@ output.elasticsearch:

#----------------------------- Logstash output --------------------------------
#output.logstash:
# Boolean flag to enable or disable the output module.
#enable: true

# The Logstash hosts
#hosts: ["localhost:5044"]

Expand Down Expand Up @@ -228,6 +234,9 @@ output.elasticsearch:

#------------------------------- Kafka output ---------------------------------
#output.kafka:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Kafka broker addresses from where to fetch the cluster metadata.
# The cluster metadata contain the actual Kafka brokers events are published
# to.
Expand Down Expand Up @@ -316,6 +325,9 @@ output.elasticsearch:

#------------------------------- Redis output ---------------------------------
#output.redis:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Redis servers to connect to. If load balancing is enabled, the
# events are distributed to the servers in the list. If one server becomes
# unreachable, the events are distributed to the reachable servers only.
Expand Down Expand Up @@ -412,6 +424,9 @@ output.elasticsearch:

#------------------------------- File output ----------------------------------
#output.file:
# Boolean flag to enable or disable the output module.
#enable: true

# Path to the directory where to save the generated files. The option is
# mandatory.
#path: "/tmp/beatname"
Expand All @@ -433,6 +448,9 @@ output.elasticsearch:

#----------------------------- Console output ---------------------------------
#output.console:
# Boolean flag to enable or disable the output module.
#enable: true

# Pretty print json event
#pretty: false

Expand Down
12 changes: 12 additions & 0 deletions libbeat/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ func (c *Config) SetChild(name string, idx int, value *Config) error {
return c.access().SetChild(name, idx, value.access(), ucfg.PathSep("."))
}

func (c *Config) Enabled() bool {
testEnabled := struct {
Enabled bool `config:"enable"`
}{true}

if err := c.Unpack(&testEnabled); err != nil {
// if unpacking fails, expect 'enable' being set to default value
return true
}
return testEnabled.Enabled
}

func fromConfig(in *ucfg.Config) *Config {
return (*Config)(in)
}
Expand Down
43 changes: 43 additions & 0 deletions libbeat/docs/outputconfig.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ output.elasticsearch:

You can specify the following options in the `elasticsearch` section of the +{beatname_lc}.yml+ config file:

===== enable

The enable config is a boolean setting to enable or disable the output. If set
to false, the output is disabled.

The default value is true.


[[hosts-option]]
===== hosts

Expand Down Expand Up @@ -357,6 +365,13 @@ output.logstash:
You can specify the following options in the `logstash` section of the
+{beatname_lc}.yml+ config file:

===== enable

The enable config is a boolean setting to enable or disable the output. If set
to false, the output is disabled.

The default value is true.

[[hosts]]
===== hosts

Expand Down Expand Up @@ -491,6 +506,13 @@ The Kafka output sends the events to Apache Kafka.

You can specify the following options in the `kafka` section of the +{beatname_lc}.yml+ config file:

===== enable

The enable config is a boolean setting to enable or disable the output. If set
to false, the output is disabled.

The default value is true.

===== hosts

The list of Kafka broker addresses from where to fetch the cluster metadata.
Expand Down Expand Up @@ -602,6 +624,13 @@ output.redis:

You can specify the following options in the `redis` section of the +{beatname_lc}.yml+ config file:

===== enable

The enable config is a boolean setting to enable or disable the output. If set
to false, the output is disabled.

The default value is true.

===== hosts

The list of Redis servers to connect to. If load balancing is enabled, the events are
Expand Down Expand Up @@ -746,6 +775,13 @@ output.file:

You can specify the following options in the `file` section of the +{beatname_lc}.yml+ config file:

===== enable

The enable config is a boolean setting to enable or disable the output. If set
to false, the output is disabled.

The default value is true.

[[path]]
===== path

Expand Down Expand Up @@ -787,6 +823,13 @@ You can specify the following options in the `console` section of the +{beatname

If `pretty` is set to true, events written to stdout will be nicely formatted. The default is false.

===== enable

The enable config is a boolean setting to enable or disable the output. If set
to false, the output is disabled.

The default value is true.

===== bulk_max_size

The maximum number of events to buffer internally during publishing. The default is 2048.
Expand Down
11 changes: 7 additions & 4 deletions libbeat/outputs/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ type bulkOutputAdapter struct {
Outputer
}

var enabledOutputPlugins = make(map[string]OutputBuilder)
var outputsPlugins = make(map[string]OutputBuilder)

func RegisterOutputPlugin(name string, builder OutputBuilder) {
enabledOutputPlugins[name] = builder
outputsPlugins[name] = builder
}

func FindOutputPlugin(name string) OutputBuilder {
return enabledOutputPlugins[name]
return outputsPlugins[name]
}

func InitOutputs(
Expand All @@ -67,11 +67,14 @@ func InitOutputs(
topologyExpire int,
) ([]OutputPlugin, error) {
var plugins []OutputPlugin = nil
for name, plugin := range enabledOutputPlugins {
for name, plugin := range outputsPlugins {
config, exists := configs[name]
if !exists {
continue
}
if !config.Enabled() {
continue
}

if !config.HasField("index") {
config.SetString("index", -1, beatName)
Expand Down
18 changes: 18 additions & 0 deletions metricbeat/metricbeat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ metricbeat.modules:

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Boolean flag to enable or disable the output module.
#enable: true

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (http and 9200)
# In case you specify and additional path, the scheme is required: http://localhost:9200/path
Expand Down Expand Up @@ -323,6 +326,9 @@ output.elasticsearch:

#----------------------------- Logstash output --------------------------------
#output.logstash:
# Boolean flag to enable or disable the output module.
#enable: true

# The Logstash hosts
#hosts: ["localhost:5044"]

Expand Down Expand Up @@ -373,6 +379,9 @@ output.elasticsearch:

#------------------------------- Kafka output ---------------------------------
#output.kafka:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Kafka broker addresses from where to fetch the cluster metadata.
# The cluster metadata contain the actual Kafka brokers events are published
# to.
Expand Down Expand Up @@ -461,6 +470,9 @@ output.elasticsearch:

#------------------------------- Redis output ---------------------------------
#output.redis:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Redis servers to connect to. If load balancing is enabled, the
# events are distributed to the servers in the list. If one server becomes
# unreachable, the events are distributed to the reachable servers only.
Expand Down Expand Up @@ -557,6 +569,9 @@ output.elasticsearch:

#------------------------------- File output ----------------------------------
#output.file:
# Boolean flag to enable or disable the output module.
#enable: true

# Path to the directory where to save the generated files. The option is
# mandatory.
#path: "/tmp/metricbeat"
Expand All @@ -578,6 +593,9 @@ output.elasticsearch:

#----------------------------- Console output ---------------------------------
#output.console:
# Boolean flag to enable or disable the output module.
#enable: true

# Pretty print json event
#pretty: false

Expand Down
18 changes: 18 additions & 0 deletions packetbeat/packetbeat.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ packetbeat.protocols.nfs:

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Boolean flag to enable or disable the output module.
#enable: true

# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (http and 9200)
# In case you specify and additional path, the scheme is required: http://localhost:9200/path
Expand Down Expand Up @@ -562,6 +565,9 @@ output.elasticsearch:

#----------------------------- Logstash output --------------------------------
#output.logstash:
# Boolean flag to enable or disable the output module.
#enable: true

# The Logstash hosts
#hosts: ["localhost:5044"]

Expand Down Expand Up @@ -612,6 +618,9 @@ output.elasticsearch:

#------------------------------- Kafka output ---------------------------------
#output.kafka:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Kafka broker addresses from where to fetch the cluster metadata.
# The cluster metadata contain the actual Kafka brokers events are published
# to.
Expand Down Expand Up @@ -700,6 +709,9 @@ output.elasticsearch:

#------------------------------- Redis output ---------------------------------
#output.redis:
# Boolean flag to enable or disable the output module.
#enable: true

# The list of Redis servers to connect to. If load balancing is enabled, the
# events are distributed to the servers in the list. If one server becomes
# unreachable, the events are distributed to the reachable servers only.
Expand Down Expand Up @@ -796,6 +808,9 @@ output.elasticsearch:

#------------------------------- File output ----------------------------------
#output.file:
# Boolean flag to enable or disable the output module.
#enable: true

# Path to the directory where to save the generated files. The option is
# mandatory.
#path: "/tmp/packetbeat"
Expand All @@ -817,6 +832,9 @@ output.elasticsearch:

#----------------------------- Console output ---------------------------------
#output.console:
# Boolean flag to enable or disable the output module.
#enable: true

# Pretty print json event
#pretty: false

Expand Down
Loading