fluent-plugin-json-nest2flat 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39aa031bc4ca3dbbcfe8dc1fbe323561e6cead35
4
- data.tar.gz: 2c0999c66deae40b1b019a587677a2aa556e79d3
3
+ metadata.gz: e45093d5cca9ffa3fbb1402e56e2347f887e234f
4
+ data.tar.gz: 648dfeb3aa5d8b18ebc3622d93145ce2e4b97024
5
5
  SHA512:
6
- metadata.gz: 0321d7477d85008676f44a9e34755a1bfe3a225099757cbd840e2b10616280241e16805c07597e4700401b524d4b6e12f3e78c0582af7b69d630692ee07e905d
7
- data.tar.gz: 20fb960d5b8b13fac4257d05628b2aba5446329a4ae2cef29e5076a950e60637012f86968ede9205f4d3d5e231a68cbf88d1f051e58d027876c5ac613e30c589
6
+ metadata.gz: 78b95b15bb6899e345463120c5cddd9496113764952bac421e4beff856e8e9ad9b43a28ffb71be6cc7274c861a63aaa1d3a07da80d1cf3164a84224f7067b0b1
7
+ data.tar.gz: e404e4dc5d0ec9f4455ae53018a9b718d4a1dcf3f12a619d7b60e4e4ecb8baa7c59e5b326ea8a8333a53455461e92a50622528894697dc83f5673d76a6ec6093
data/README.md CHANGED
@@ -1,24 +1,43 @@
1
1
  # fluent-plugin-json-nest2flat
2
2
  # Overview
3
3
 
4
- json_nest2flat is a fluentd output plugin.
5
- I will convert data into a flat data structure of JSON nested.
4
+ json_nest2flat is a fluentd output plugin.I will convert data into a flat data structure of JSON nested.
6
5
 
7
- ex. {hoge”:1, foo”:2, data”:{"name":"taro", "age":18, "height":175}} -> ex. {hoge”:1, foo”:2, "name":"taro", "age":18, "height":175}
6
+ ex. {"hoge":1, "foo":2, "data":{"name":"taro", "age":18, "height":175}} -> ex. {"hoge":1, "foo":2, "name":"taro", "age":18, "height":175}
8
7
 
8
+ [I am writing in my blog, such as the history of release](http://f-retu.hatenablog.com/entry/2013/12/24/235908)
9
9
 
10
10
  # Configuration
11
+ ex1.
11
12
 
12
13
  <match pattern>
13
14
  type json_nest2flat
15
+ tag json_nest2flat.finished
16
+ json_keys data1,data2,data3
17
+ </match>
18
+
19
+
20
+ ex2.
21
+
22
+ <match pattern>
23
+ type json_nest2flat
24
+ add_tag_prefix json_nest2flat
14
25
  json_keys data1,data2,data3
15
26
  </match>
16
27
 
17
28
  # Parameters
29
+ * tag
30
+
31
+ The output tag. add_tag_prefix or tag is required.
32
+
33
+ * add_tag_prefix
34
+
35
+ To add a prefix to the tag that matched. Tag, is enabled if both are specified tag and if, add_tag_prefix is ignored.
36
+
18
37
  * json_keys
19
38
 
20
39
  It is the key that you want to convert to a flat structure from JSON nested. It is more than one can be specified in a comma-separated.
21
-
40
+
22
41
  # TODO
23
42
 
24
43
  Currently, nested structure of two or more layers will be unexpected.
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "fluent-plugin-json-nest2flat"
4
- spec.version = "0.0.2"
4
+ spec.version = "0.0.3"
5
5
  spec.authors = ["Fukui ReTu"]
6
6
  spec.email = ["s0232101@gmail.com"]
7
7
  spec.description = %q{Output filter plugin to convert to a flat structure the JSON that is nest}
@@ -3,7 +3,8 @@ module Fluent
3
3
 
4
4
  Fluent::Plugin.register_output('json_nest2flat', self)
5
5
 
6
- config_param :tag, :string, :default => 'json_nest2flat'
6
+ config_param :tag, :string, :default => nil
7
+ config_param :add_tag_prefix, :string, :default => nil
7
8
  config_param :json_keys, :string, :default => nil
8
9
 
9
10
  def configure(conf)
@@ -11,10 +12,20 @@ module Fluent
11
12
 
12
13
  @json_keys = conf['json_keys']
13
14
  if @json_keys.nil?
14
- raise Fluent::ConfigError, "json_keys is undefined!"
15
+ raise Fluent::ConfigError, "json_keys is required!"
15
16
  end
16
17
 
17
18
  @tag = conf['tag']
19
+ @add_tag_prefix = conf['add_tag_prefix']
20
+ if @tag.nil? && @add_tag_prefix.nil?
21
+ raise Fluent::ConfigError, "tag or add_tag_prefix is required!"
22
+ end
23
+
24
+ @enabled_tag = false
25
+ if !@tag.nil?
26
+ @enabled_tag = true
27
+ end
28
+
18
29
  @json_keys = @json_keys.split(",")
19
30
  end
20
31
 
@@ -24,7 +35,11 @@ module Fluent
24
35
 
25
36
  new_record = _convert_record(record);
26
37
 
27
- Fluent::Engine.emit(@tag, time, new_record)
38
+ if @enabled_tag
39
+ Fluent::Engine.emit(@tag, time, new_record)
40
+ else
41
+ Fluent::Engine.emit("#{@add_tag_prefix}.#{tag}", time, new_record)
42
+ end
28
43
  }
29
44
  end
30
45
 
@@ -50,7 +65,7 @@ module Fluent
50
65
  end
51
66
  }
52
67
 
53
- unless json_keys_exist_count == 0
68
+ unless json_keys_exist_count > 0
54
69
  $log.warn "json_keys is not found."
55
70
  end
56
71
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-json-nest2flat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fukui ReTu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-25 00:00:00.000000000 Z
11
+ date: 2013-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler