fluent-plugin-jsonish 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- _ S�,�8�&�16Q,b�x��$Ğ��%-KW����*�=��
2
- ���U�cЖG�nz8���ǽ7U'�m1U.��4t�>뛠?
1
+ ���mH=�������e?�.�Lv]�8F{��8c����[qt�l� �>w��<}Wan�bA�V���,�D��9���j�x�(����T�)�"ԙ�jsk�ȉ�+H�so;�s%�s�}�������Jy�@s_6�fH����x>����ݼ�!,H�_�)��X�,�.�?:S�^���2�H�
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # jsonish, nginx_jsonish, and nodejs_bunyan parser plugins for Fluentd
1
+ # jsonish, nginx_jsonish, nodejs_bunyan, and logstash parser plugins for Fluentd
2
2
 
3
3
  ## Overview
4
4
  The jsonish [parser plugin](http://docs.fluentd.org/articles/parser-plugin-overview) for fluentd. It subclasses the JSONParser to allow for modifications to be made to input test before it is deserialized. It subclasses the TimeParser to allow time format specifications using Ruby Time class method names instead of strftime format strings -- in particular, the iso8601 method.
@@ -29,6 +29,7 @@ gem install fluent-plugin-jsonish
29
29
  null_maps <how the patterns specified by null_pattern should be replaced>
30
30
  message_key <key to use for setting the 'message' key in the record>
31
31
  add_full_message <whether to the record 'full_message' key to the raw input>
32
+ move_keys <hash in JSON format, defaults to {}>
32
33
  </source>
33
34
  ```
34
35
 
@@ -39,6 +40,8 @@ gem install fluent-plugin-jsonish
39
40
 
40
41
  `maps`: an array containing "nulls", "slashes", or two-valued arrays containg (regex,replacement_text) pairs. Defaults to [].
41
42
 
43
+ `move_keys`: a hash specifying keys which should be moved after deseralization. Each key should be the name of the key expected in the input JSON, and the corresponding value is the what the key needs to be in the record. Use a null value to delete a key from the record.
44
+
42
45
  `null_pattern`: the pattern for how nulls are represented in the text. Defaults to "-" (what nginx uses).
43
46
 
44
47
  `null_maps`: the an JSON array of two-valued arrays containing a sprintf regex string and substitution text (JSON: default [ [ \"(:\\s+)\"%s\"(\\s*[,}])\", \"\\1null\\2\" ], [ \"(:\\s+)%s(\\s*[,}])\", \"\\1null\\2\" ], [ \"(:\\s+)\\[\\s*%s\\s*\\](\\s*[,}])\", \"\\1[]\\2\" ], [ \"(:\\s+){\\s*%s\\*}(\\s*[,}])\", \"\\1{}\\2\" ] ])
@@ -97,3 +100,17 @@ The fluentd parser configuration for this input is straight-forward:
97
100
  [ standard parser or jsonish arguments ]
98
101
  </source>
99
102
  ```
103
+
104
+ ### logstash
105
+ This is a parser for inputs whicare in [Logstash](https://gist.github.com/jordansissel/2996677) format. Only two keys are required in this format ("@timestamp" and "@version"). The parser automatically maps "@timestamp" to time. Both the "@version" and "@timestamp" keys are deleted, since they are part of the Logstash event meta data, not actual event data.
106
+
107
+ The fluentd parser configuration for this input is straight-forward:
108
+
109
+ ```
110
+ <source>
111
+ type tail
112
+ format logstash
113
+ path <application log file name>
114
+ [ standard parser or jsonish arguments ]
115
+ </source>
116
+ ```
@@ -46,6 +46,7 @@ module Fluent
46
46
  ]
47
47
  config_param :message_key, :string, :default => nil
48
48
  config_param :add_full_message, :bool, :default => false
49
+ config_param :move_keys, :hash, :default => {}
49
50
 
50
51
  def initialize
51
52
  super
@@ -94,9 +95,6 @@ module Fluent
94
95
  end
95
96
  end
96
97
 
97
- @message_key = conf['message_key']
98
- @add_full_message = conf['add_full_message']
99
-
100
98
  end
101
99
 
102
100
  def parse(text)
@@ -116,6 +114,11 @@ module Fluent
116
114
  record['full_message'] = full_message
117
115
  end
118
116
 
117
+ @move_keys.map do |k,v|
118
+ record[v] = record.delete(k)
119
+ end
120
+ record.delete(nil)
121
+
119
122
  yield time, record
120
123
  end
121
124
 
@@ -0,0 +1,16 @@
1
+ require_relative 'parser_jsonish'
2
+
3
+ module Fluent
4
+ class TextParser
5
+ class NodejsLogstash < JSONishParser
6
+ Plugin.register_parser('logstash', self)
7
+
8
+ def configure(conf)
9
+ super(conf)
10
+ @time_key = '@timestamp'
11
+ @move_keys.update({ '@version' => nil, '@timestamp' => nil })
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -8,18 +8,18 @@ module Fluent
8
8
 
9
9
  def configure(conf)
10
10
 
11
- if conf['maps'].is_a?(Array)
12
- conf['maps'] = ([ 'slashes', 'nulls' ] + conf['maps']).uniq
11
+ if conf.key?('maps')
12
+ conf['maps'] = ([ 'slashes', 'nulls' ] + JSON.parse(conf['maps'])).uniq.to_json
13
13
  else
14
- conf['maps'] = [ 'slashes', 'nulls' ]
15
- end
16
-
17
- if not (conf['message_key'] and conf['message_key'].is_empty?)
18
- conf['message_key'] = 'request'
14
+ conf['maps'] = [ 'slashes', 'nulls' ].to_json
19
15
  end
20
16
 
21
17
  super(conf)
22
18
 
19
+ if @message_key.nil? or @message_key.empty?
20
+ @message_key = 'request'
21
+ end
22
+
23
23
  end
24
24
 
25
25
  end
@@ -6,22 +6,16 @@ module Fluent
6
6
  Plugin.register_parser('nodejs_bunyan', self)
7
7
 
8
8
  def configure(conf)
9
- super(conf.update({ 'time_key' => 'time', 'message_key' => 'msg'}))
9
+ super(conf)
10
+ @time_key = 'time'
11
+ @message_key = 'msg'
12
+ @move_keys.update({ 'v' => nil, 'msg' => nil, 'hostname' => 'host' })
10
13
  end
11
14
 
12
15
  def parse(text)
13
16
  super(text) do |time, record|
14
17
  # Map the developer-defined levels to syslog levels.
15
18
  record['level'] = 8+(record['level']<=30?1:0)-(record['level']/10)
16
- # Cannot be disabled in the library and serves no purpose,
17
- # since it never varies.
18
- record.delete('v')
19
- # Fluent expects the host to be keyed with 'host', not 'hostname'.
20
- record['host'] = record.delete('hostname')
21
- record.delete('hostname')
22
- # Passing 'message_key' only duplicates the key to 'message' --
23
- # it does not delete the original key (which is unneeded).
24
- record.delete(@message_key)
25
19
  yield time, record
26
20
  end
27
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-jsonish
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Yamauchi
@@ -41,7 +41,7 @@ cert_chain:
41
41
  2Zk648Ep9HVPKmwoVuB75+xEQw==
42
42
  -----END CERTIFICATE-----
43
43
 
44
- date: 2017-06-16 00:00:00 Z
44
+ date: 2017-08-17 00:00:00 Z
45
45
  dependencies:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: fluentd
@@ -76,6 +76,7 @@ files:
76
76
  - certs/oss@hotschedules.com.cert
77
77
  - fluent-plugin-jsonish.gemspec
78
78
  - lib/fluent/plugin/parser_jsonish.rb
79
+ - lib/fluent/plugin/parser_logstash.rb
79
80
  - lib/fluent/plugin/parser_nginx_jsonish.rb
80
81
  - lib/fluent/plugin/parser_nodejs_bunyan.rb
81
82
  homepage: https://github.com/bodhi-space/fluent-plugin-jsonish
metadata.gz.sig CHANGED
Binary file