Skip to content

Commit 58c0f6c

Browse files
dforstepcfens
authored andcommitted
Update input.erb to use new parsers
1 parent 5108c44 commit 58c0f6c

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

templates/input.yml.erb

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<%- if @pure_array -%>
22
<%= scope['filebeat::inputs'].to_yaml() %>
33
<%- else -%>
4+
<%- if @input_type == 'filestream'
5+
parsers = @parsers
6+
if @multiline != {}
7+
parsers << {'multiline' => @multiline }
8+
end
9+
if @json != {}
10+
parsers << {'ndjson' => @json }
11+
end
12+
end -%>
413
---
514
- type: <%= @input_type %>
615
<%- if @input_type =~ /(filestream|journald)/ -%>
@@ -120,8 +129,8 @@
120129
<%- if @force_close_files -%>
121130
force_close_files: <%= @force_close_files %>
122131
<%- end -%>
123-
<%- if @json.length > 0 -%>
124-
###JSON configuration
132+
<%- if @json != {} && @input_type != 'filestream'-%>
133+
###JSON configuration
125134
json:
126135
# Decode JSON options. Enable this if your logs are structured in JSON.
127136
# JSON key on which to apply the line filtering and multiline settings. This key
@@ -172,35 +181,11 @@
172181
ignore_decoding_error: <%= @json['ignore_decoding_error'] %>
173182
<%- end -%>
174183
<%- end -%>
175-
<%- if @multiline.length > 0 -%>
176-
<%- if @input_type == 'filestream' -%>
184+
<%- if parsers != [] -%>
177185
parsers:
178-
- multiline:
179-
<%- if @multiline['pattern'] -%>
180-
pattern: '<%= @multiline['pattern'] %>'
181-
<%- end -%>
182-
<%- if @multiline['negate'] -%>
183-
negate: <%= @multiline['negate'] %>
184-
<%- end -%>
185-
<%- if @multiline['match'] -%>
186-
match: <%= @multiline['match'] %>
187-
<%- end -%>
188-
<%- if @multiline['flush_pattern'] -%>
189-
flush_pattern: <%= @multiline['flush_pattern'] %>
190-
<%- end -%>
191-
<%- if @multiline['max_lines'] -%>
192-
max_lines: <%= @multiline['max_lines'] %>
193-
<%- end -%>
194-
<%- if @multiline['count_lines'] -%>
195-
count_lines: <%= @multiline['count_lines'] %>
196-
<%- end -%>
197-
<%- if @multiline['timeout'] -%>
198-
timeout: <%= @multiline['timeout'] %>
199-
<%- end -%>
200-
<%- if @multiline['skip_newline'] -%>
201-
skip_newline: <%= @multiline['skip_newline'] %>
202-
<%- end -%>
203-
<%- else -%>
186+
<%= parsers.to_yaml.lines.drop(1).join.gsub(/^/, ' ') %>
187+
<%- end -%>
188+
<%- if @multiline != {} && @input_type != 'filestream' -%>
204189
multiline:
205190
<%- if @multiline['pattern'] -%>
206191
pattern: '<%= @multiline['pattern'] %>'
@@ -227,7 +212,6 @@
227212
skip_newline: <%= @multiline['skip_newline'] %>
228213
<%- end -%>
229214
<%- end -%>
230-
<%- end -%>
231215
tail_files: <%= @tail_files %>
232216

233217
# Experimental: If symlinks is enabled, symlinks are opened and harvested. The harvester is openening the

0 commit comments

Comments
 (0)