Skip to content

Commit

Permalink
Adding support for Processors.
Browse files Browse the repository at this point in the history
As described in the comments of templates/filebeat5.yml.erb and in
https://www.elastic.co/guide/en/beats/filebeat/current/configuration-processors.html,
we are providing puppet functionality to configure processors in filebeat.
  • Loading branch information
corey-hammerton committed Jan 1, 2017
1 parent 2d3d240 commit 90e70af
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'shipper' => $filebeat::shipper,
'logging' => $filebeat::logging,
'runoptions' => $filebeat::run_options,
'processors' => $filebeat::processors,
})

case $::kernel {
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# @param max_procs [Number] The maximum number of CPUs that can be simultaneously used
# @param fields [Hash] Optional fields that should be added to each event output
# @param fields_under_root [Boolean] If set to true, custom fields are stored in the top level instead of under fields
# @param processors [Array] An optional list of hashes used to configure filebeat processors
# @param prospectors [Hash] Prospectors that will be created. Commonly used to create prospectors using hiera
# @param prospectors_merge [Boolean] Whether $prospectors should merge all hiera sources, or use simple automatic parameter lookup
class filebeat (
Expand Down Expand Up @@ -77,6 +78,7 @@
$max_procs = $filebeat::params::max_procs,
$fields = $filebeat::params::fields,
$fields_under_root = $filebeat::params::fields_under_root,
$processors = $filebeat::params::processors,
#### End v5 onlly ####
$prospectors = {},
$prospectors_merge = false,
Expand Down Expand Up @@ -125,6 +127,7 @@
warning('You\'ve specified a non-standard config_file location - filebeat may fail to start unless you\'re doing something to fix this')
}

validate_array($processors)
validate_hash($outputs, $logging, $prospectors_final)
validate_string($idle_timeout, $registry_file, $config_dir, $package_ensure)

Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$logging = {}
$run_options = {}
$use_generic_template = false
$processors = []

# These are irrelevant as long as the template is set based on the major_version parameter
# if versioncmp('1.9.1', $::rubyversion) > 0 {
Expand Down
26 changes: 26 additions & 0 deletions templates/filebeat5.yml.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
<%-
def yaml_indent(conds, idx=4)
return_val = []
tmp_val = conds.to_yaml.split("\n")
tmp_val.delete('---')

tmp_val.each do |val|
return_val << " " + val
end

return_val.join("\n")
end
-%>
#========================= Filebeat global options ============================

filebeat.spool_size: <%= @filebeat_config['filebeat']['spool_size'] %>
Expand Down Expand Up @@ -63,6 +76,19 @@ max_procs: <%= @filebeat_config['max_procs'] %>
# equals:
# http.code: 200
#
<%- unless @filebeat_config['processors'].empty? -%>
processors:
<%- @filebeat_config['processors'].each do |_proc| -%>
- <%= _proc['name'] %>:
<%- unless _proc['when'].nil? or _proc['when'].empty? -%>
when:
<%= yaml_indent(_proc['when']) %>
<%- end -%>
<%- _proc['params'].each do |key,val|-%>
<%= key %>: <%= val %>
<%- end -%>
<%- end -%>
<%- end -%>

#================================ Outputs =====================================

Expand Down

0 comments on commit 90e70af

Please sign in to comment.