From 72e6bcd744bbce6bb94f75c9b6103b275adce9ee Mon Sep 17 00:00:00 2001 From: pilchkinstein-gtv Date: Fri, 2 Mar 2018 22:32:51 +0000 Subject: [PATCH 1/2] Implemented , etc sections within fluentd::source template - Changed templates/source.erb to accept Hash elements within 'config' - Updated source_spec test - Updated README.md --- README.md | 16 ++++++++++++++++ examples/source.pp | 8 ++++++++ spec/defines/source_spec.rb | 8 ++++++++ spec/fixtures/files/source_tail.conf | 8 ++++++++ templates/source.erb | 8 ++++++++ 5 files changed, 48 insertions(+) diff --git a/README.md b/README.md index 28b8b00..11f6e56 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,14 @@ include '::fluentd' 'type' => 'tail', 'format' => 'json', 'path' => '/var/log/test-application/*.json', + 'parse' => { + 'type' => 'regexp', + 'expression' => '^(?[^ ]*) (?[^ ]*) (?\d*)$' + }, + 'storage'=> { + 'type' => 'local', + 'path' => 'test.pos' + }, 'tag' => 'application.test' } } @@ -142,6 +150,14 @@ include '::fluentd' type tail format json path /var/log/test-application/*.json + + type regexp + expression ^(?[^ ]*) (?[^ ]*) (?\d*)$ + + + type local + path test.pos + tag application.test ``` diff --git a/examples/source.pp b/examples/source.pp index 4488950..ec1dee8 100644 --- a/examples/source.pp +++ b/examples/source.pp @@ -5,6 +5,14 @@ 'type' => 'tail', 'format' => 'json', 'path' => '/var/log/test-application/*.json', + 'parse' => { + 'type' => 'regexp', + 'expression' => '^(?[^ ]*) (?[^ ]*) (?\d*)$' + }, + 'storage'=> { + 'type' => 'local', + 'path' => 'test.pos' + }, 'tag' => 'application.test' } } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index b9b098a..1b68382 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -18,6 +18,14 @@ describe 'fluentd::source' do 'type' => 'tail', 'format' => 'json', 'path' => '/var/log/test-application/*.json', + 'parse' => { + 'type' => 'regexp', + 'expression' => '^(?[^ ]*) (?[^ ]*) (?\d*)$' + }, + 'storage'=> { + 'type' => 'local', + 'path' => 'test.pos' + }, 'tag' => 'application.test' } } diff --git a/spec/fixtures/files/source_tail.conf b/spec/fixtures/files/source_tail.conf index 4eb4061..bd28b2f 100644 --- a/spec/fixtures/files/source_tail.conf +++ b/spec/fixtures/files/source_tail.conf @@ -2,5 +2,13 @@ type tail format json path /var/log/test-application/*.json + + type regexp + expression ^(?[^ ]*) (?[^ ]*) (?\d*)$ + + + type local + path test.pos + tag application.test diff --git a/templates/source.erb b/templates/source.erb index 04f119a..d047690 100644 --- a/templates/source.erb +++ b/templates/source.erb @@ -1,5 +1,13 @@ <% @config.each do |key, val| -%> + <%- if val.is_a?( Hash ) -%> + <<%= key -%>> + <%- val.each do |key2, val2| -%> + <%= key2 -%> <%= val2 %> + <%- end -%> + > + <%- else -%> <%= key -%> <%= val %> + <%- end -%> <% end -%> From 29122932ef39f8b55f975083ebb2413a9f117c4f Mon Sep 17 00:00:00 2001 From: pilchkinstein-gtv Date: Fri, 2 Mar 2018 23:22:13 +0000 Subject: [PATCH 2/2] Fixed lint warnings --- examples/source.pp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/source.pp b/examples/source.pp index ec1dee8..0c2a9c2 100644 --- a/examples/source.pp +++ b/examples/source.pp @@ -2,17 +2,17 @@ ::fluentd::source { 'test': priority => 10, config => { - 'type' => 'tail', - 'format' => 'json', - 'path' => '/var/log/test-application/*.json', - 'parse' => { - 'type' => 'regexp', - 'expression' => '^(?[^ ]*) (?[^ ]*) (?\d*)$' + 'type' => 'tail', + 'format' => 'json', + 'path' => '/var/log/test-application/*.json', + 'parse' => { + 'type' => 'regexp', + 'expression' => '^(?[^ ]*) (?[^ ]*) (?\d*)$' }, - 'storage'=> { - 'type' => 'local', - 'path' => 'test.pos' + 'storage' => { + 'type' => 'local', + 'path' => 'test.pos' }, - 'tag' => 'application.test' + 'tag' => 'application.test' } }