fluent-plugin-norikra 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +4 -1
 - data/fluent-plugin-norikra.gemspec +1 -1
 - data/lib/fluent/plugin/norikra/config_section.rb +2 -1
 - data/lib/fluent/plugin/norikra/target.rb +25 -1
 - data/test/test_target.rb +41 -0
 - metadata +15 -15
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e29c9f16d25507902aaf3dd02a7b43e1596880ca
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: bc441ac622bbeb6f9c9b40b1eefcd8fd5efc2277
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4b95d21010ab1989e74ccbd19407220af2855bdb1333324edbdf4082ed210e5aa6a0deec663391ea386c478480f093103f2083138fdc184645cdce6a4b72b81f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c57fe2a8e659919719bf457b4b3eb7215b89d9eec56e77841cec3789ac46285dd392dd0149d397a3994c6b2a79b57c53f190609ed799e54a62504c2baa02e29d
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -64,7 +64,10 @@ NorikraOutput plugin opens Norikra's target for newly incoming tags. You can spe 
     | 
|
| 
       64 
64 
     | 
    
         
             
                include *     # send all fields values to norikra
         
     | 
| 
       65 
65 
     | 
    
         
             
                exclude time  # exclude 'time' field from sending event values
         
     | 
| 
       66 
66 
     | 
    
         
             
                   # AND/OR 'include_regexp' and 'exclude_regexp' available
         
     | 
| 
       67 
     | 
    
         
            -
                field_integer seq 
     | 
| 
      
 67 
     | 
    
         
            +
                field_integer seq    # field 'seq' defined as integer for all targets
         
     | 
| 
      
 68 
     | 
    
         
            +
                escape_fieldname yes # Escape field name special chars (non alphabetical or numerical names) with underscore('_')
         
     | 
| 
      
 69 
     | 
    
         
            +
                                     #  This is friendly for query access (ex: field.key1.cpu_total)
         
     | 
| 
      
 70 
     | 
    
         
            +
                                     #  Default: no
         
     | 
| 
       68 
71 
     | 
    
         
             
              </default>
         
     | 
| 
       69 
72 
     | 
    
         | 
| 
       70 
73 
     | 
    
         
             
              <target users>
         
     | 
| 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       4 
4 
     | 
    
         
             
              spec.name          = "fluent-plugin-norikra"
         
     | 
| 
       5 
     | 
    
         
            -
              spec.version       = "0.1. 
     | 
| 
      
 5 
     | 
    
         
            +
              spec.version       = "0.1.1"
         
     | 
| 
       6 
6 
     | 
    
         
             
              spec.authors       = ["TAGOMORI Satoshi"]
         
     | 
| 
       7 
7 
     | 
    
         
             
              spec.email         = ["tagomoris@gmail.com"]
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.description   = %q{process events on fluentd with SQL like query, with built-in Norikra server if needed.}
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Fluent::NorikraPlugin
         
     | 
| 
       2 
2 
     | 
    
         
             
              class ConfigSection
         
     | 
| 
       3 
     | 
    
         
            -
                attr_accessor :target, :target_matcher, :auto_field, :filter_params, :field_definitions, :query_generators
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_accessor :target, :target_matcher, :auto_field, :escape_fieldname, :filter_params, :field_definitions, :query_generators
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                def initialize(section, enable_auto_query=true)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  @target = nil
         
     | 
| 
         @@ -16,6 +16,7 @@ module Fluent::NorikraPlugin 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                  @auto_field = Fluent::Config.bool_value(section['auto_field'])
         
     | 
| 
      
 19 
     | 
    
         
            +
                  @escape_fieldname = Fluent::Config.bool_value(section['escape_fieldname'])
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
                  @filter_params = {
         
     | 
| 
       21 
22 
     | 
    
         
             
                    :include => section['include'],
         
     | 
| 
         @@ -24,6 +24,7 @@ module Fluent::NorikraPlugin 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  @name = target
         
     | 
| 
       25 
25 
     | 
    
         
             
                  @escaped_name = self.class.escape(@name)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  @auto_field = config.auto_field.nil? ? true : config.auto_field
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @escape_fieldname = config.escape_fieldname
         
     | 
| 
       27 
28 
     | 
    
         | 
| 
       28 
29 
     | 
    
         
             
                  @filter = RecordFilter.new(*([:include, :include_regexp, :exclude, :exclude_regexp].map{|s| config.filter_params[s]}))
         
     | 
| 
       29 
30 
     | 
    
         
             
                  @fields = config.field_definitions
         
     | 
| 
         @@ -31,7 +32,30 @@ module Fluent::NorikraPlugin 
     | 
|
| 
       31 
32 
     | 
    
         
             
                end
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
34 
     | 
    
         
             
                def filter(record)
         
     | 
| 
       34 
     | 
    
         
            -
                  @filter.filter(record)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  r = @filter.filter(record)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  if @escape_fieldname
         
     | 
| 
      
 37 
     | 
    
         
            +
                    escape_recursive(r)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  else
         
     | 
| 
      
 39 
     | 
    
         
            +
                    r
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                def escape_recursive(record)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  return record unless record.is_a?(Hash) || record.is_a?(Array)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  return record.map{|v| escape_recursive(v) } if record.is_a?(Array)
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                  # Hash
         
     | 
| 
      
 48 
     | 
    
         
            +
                  r = {}
         
     | 
| 
      
 49 
     | 
    
         
            +
                  record.keys.each do |key|
         
     | 
| 
      
 50 
     | 
    
         
            +
                    k = if key =~ /[^$_a-zA-Z0-9]/
         
     | 
| 
      
 51 
     | 
    
         
            +
                          key.gsub(/[^$_a-zA-Z0-9]/, '_')
         
     | 
| 
      
 52 
     | 
    
         
            +
                        else
         
     | 
| 
      
 53 
     | 
    
         
            +
                          key
         
     | 
| 
      
 54 
     | 
    
         
            +
                        end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    v = escape_recursive(record[key])
         
     | 
| 
      
 56 
     | 
    
         
            +
                    r[k] = v
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
                  r
         
     | 
| 
       35 
59 
     | 
    
         
             
                end
         
     | 
| 
       36 
60 
     | 
    
         | 
| 
       37 
61 
     | 
    
         
             
                def reserve_fields
         
     | 
    
        data/test/test_target.rb
    CHANGED
    
    | 
         @@ -91,4 +91,45 @@ class TargetTest < Test::Unit::TestCase 
     | 
|
| 
       91 
91 
     | 
    
         
             
                assert_equal 'SELECT * FROM test_service.win:time_batch(30 min) WHERE q3="/"', t.queries[2].expression
         
     | 
| 
       92 
92 
     | 
    
         
             
                assert_equal 'q3.test', t.queries[2].tag
         
     | 
| 
       93 
93 
     | 
    
         
             
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              C3 = Fluent::Config::Element.new('target', 'test', {
         
     | 
| 
      
 96 
     | 
    
         
            +
                  'escape_fieldname' => 'no',
         
     | 
| 
      
 97 
     | 
    
         
            +
                }, [])
         
     | 
| 
      
 98 
     | 
    
         
            +
              S3 = Fluent::NorikraPlugin::ConfigSection.new(C3)
         
     | 
| 
      
 99 
     | 
    
         
            +
              C4 = Fluent::Config::Element.new('target', 'test', {
         
     | 
| 
      
 100 
     | 
    
         
            +
                  'escape_fieldname' => 'yes',
         
     | 
| 
      
 101 
     | 
    
         
            +
                }, [])
         
     | 
| 
      
 102 
     | 
    
         
            +
              S4 = Fluent::NorikraPlugin::ConfigSection.new(C4)
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              def test_escape_fieldname
         
     | 
| 
      
 105 
     | 
    
         
            +
                t = @this.new('test.service', S3)
         
     | 
| 
      
 106 
     | 
    
         
            +
                r = t.filter({'a 1' => '1', 'b 2' => 2, 'c-1' => { 'd/1' => '1', 'd 2' => '2' }, 'f' => [1, 2, {'g+1' => 3}] })
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_equal '1', r['a 1']
         
     | 
| 
      
 108 
     | 
    
         
            +
                assert_equal 2,   r['b 2']
         
     | 
| 
      
 109 
     | 
    
         
            +
                assert_equal '1', r['c-1']['d/1']
         
     | 
| 
      
 110 
     | 
    
         
            +
                assert_equal '2', r['c-1']['d 2']
         
     | 
| 
      
 111 
     | 
    
         
            +
                assert_equal 1,   r['f'][0]
         
     | 
| 
      
 112 
     | 
    
         
            +
                assert_equal 2,   r['f'][1]
         
     | 
| 
      
 113 
     | 
    
         
            +
                assert_equal 3,   r['f'][2]['g+1']
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                assert_nil r['a_1']
         
     | 
| 
      
 116 
     | 
    
         
            +
                assert_nil r['b_2']
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_nil r['c_1']
         
     | 
| 
      
 118 
     | 
    
         
            +
                assert_nil r['f'][2]['g_1']
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                t = @this.new('test.service', S4)
         
     | 
| 
      
 121 
     | 
    
         
            +
                r = t.filter({'a 1' => '1', 'b 2' => 2, 'c-1' => { 'd/1' => '1', 'd 2' => '2' }, 'f' => [1, 2, {'g+1' => 3}] })
         
     | 
| 
      
 122 
     | 
    
         
            +
                assert_nil r['a 1']
         
     | 
| 
      
 123 
     | 
    
         
            +
                assert_nil r['b 2']
         
     | 
| 
      
 124 
     | 
    
         
            +
                assert_nil r['c-1']
         
     | 
| 
      
 125 
     | 
    
         
            +
                assert_equal 1, r['f'][0]
         
     | 
| 
      
 126 
     | 
    
         
            +
                assert_equal 2, r['f'][1]
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert_nil r['f'][2]['g+1']
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                assert_equal '1', r['a_1']
         
     | 
| 
      
 130 
     | 
    
         
            +
                assert_equal 2,   r['b_2']
         
     | 
| 
      
 131 
     | 
    
         
            +
                assert_equal '1', r['c_1']['d_1']
         
     | 
| 
      
 132 
     | 
    
         
            +
                assert_equal '2', r['c_1']['d_2']
         
     | 
| 
      
 133 
     | 
    
         
            +
                assert_equal 3,   r['f'][2]['g_1']
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
       94 
135 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,69 +1,69 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fluent-plugin-norikra
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - TAGOMORI Satoshi
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-03-26 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: norikra-client
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - -  
     | 
| 
      
 17 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
19 
     | 
    
         
             
                    version: 0.0.7
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - -  
     | 
| 
      
 24 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: 0.0.7
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: fluentd
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - -  
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
33 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - -  
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: bundler
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
     | 
    
         
            -
                - - ~>
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       46 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
47 
     | 
    
         
             
                    version: '1.3'
         
     | 
| 
       48 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       49 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
     | 
    
         
            -
                - - ~>
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '1.3'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
56 
     | 
    
         
             
              name: rake
         
     | 
| 
       57 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - -  
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       60 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
61 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       62 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       63 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       64 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       66 
     | 
    
         
            -
                - -  
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       69 
69 
     | 
    
         
             
            description: process events on fluentd with SQL like query, with built-in Norikra
         
     | 
| 
         @@ -74,8 +74,8 @@ executables: [] 
     | 
|
| 
       74 
74 
     | 
    
         
             
            extensions: []
         
     | 
| 
       75 
75 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       76 
76 
     | 
    
         
             
            files:
         
     | 
| 
       77 
     | 
    
         
            -
            - .gitignore
         
     | 
| 
       78 
     | 
    
         
            -
            - .travis.yml
         
     | 
| 
      
 77 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 78 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
       79 
79 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       80 
80 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       81 
81 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -120,17 +120,17 @@ require_paths: 
     | 
|
| 
       120 
120 
     | 
    
         
             
            - lib
         
     | 
| 
       121 
121 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       122 
122 
     | 
    
         
             
              requirements:
         
     | 
| 
       123 
     | 
    
         
            -
              - -  
     | 
| 
      
 123 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       124 
124 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       125 
125 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       126 
126 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       127 
127 
     | 
    
         
             
              requirements:
         
     | 
| 
       128 
     | 
    
         
            -
              - -  
     | 
| 
      
 128 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       129 
129 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       130 
130 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       131 
131 
     | 
    
         
             
            requirements: []
         
     | 
| 
       132 
132 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       133 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 133 
     | 
    
         
            +
            rubygems_version: 2.2.2
         
     | 
| 
       134 
134 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       135 
135 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       136 
136 
     | 
    
         
             
            summary: Fluentd plugin to do CEP with norikra
         
     |