fluent-plugin-everysense 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c77e04a5016b57e7dc362cfcad0fbb920cce6807
4
- data.tar.gz: f98ffde7cf600e3653b1ede752fa854623684b55
3
+ metadata.gz: 71732bc5a744276424c6081b7aa3c5b0c0ac9a80
4
+ data.tar.gz: e0a0cf71e1db33a9556b28b67861cd85ccb5d098
5
5
  SHA512:
6
- metadata.gz: 80d75ae58e2500dab081e641606738e0f966ee0b2fc4a0b65525a96c27ce2db2656b0b8208d5308fc08c9653c7c381f966a2f436f845840e65ef697a13d99c66
7
- data.tar.gz: 3028ecae8d2185213aebffebb2d628deda3bc61f2a5dadef59c02181859b9109d10351980185d0478e0436ce7dd510e9cfacec4851681cb7b1ce635e50f1a565
6
+ metadata.gz: 0b2280bab8f9d46c6ce0f76ce449df84d4bba414897a4a83e15da9137d1254252d9234356bbd51d99db8c86c188eaada473f21dddcba499c896c3168009964c8
7
+ data.tar.gz: 079d63d4938f6c8c28f53db240c11accaa20d18cf207205ec02921b142c5a6281f7d3aaf8fa2be6615f9d9a7ea5f94855f9a7097512c590db6715b2fe4d4bdd8
data/README.md CHANGED
@@ -22,7 +22,7 @@ fluent-plugin-everysense has Input and Output Plugins for EverySense platform.
22
22
 
23
23
  ### Input Plugin (Fluent::EverySenseInput)
24
24
 
25
- Input Plugin can be used via source directive in the configuration.
25
+ Input Plugin can receive events from EverySense Server. It can be used via source directive in the configuration.
26
26
 
27
27
  ```
28
28
  <source>
@@ -49,19 +49,20 @@ Since each device may have multiple sensors, time field is generated when Input
49
49
  ```
50
50
  {"json":
51
51
  [
52
- {"data": {
52
+ { "data": {
53
53
  "at": "2016-05-15 12:14:30 +0900",
54
54
  "unit":"degree Celsius",
55
55
  "value":23
56
56
  },
57
- "sensor_name":"collection_data_1"
57
+ "sensor_name":"collection_data_1"
58
58
  },
59
- {"data": {
59
+ { "data": {
60
60
  "at":"2016-05-15 12:14:30 +0900",
61
61
  "unit":"%RH",
62
62
  "value":30
63
63
  },
64
- "sensor_name":"collection_data_2"}
64
+ "sensor_name":"collection_data_2"
65
+ }
65
66
  ]
66
67
  }
67
68
  ```
@@ -70,7 +71,7 @@ While fluentd record must be a map (Hash), the output of EverySense becomes an a
70
71
 
71
72
  ### Output Plugin (Fluent::EverySenseOutput)
72
73
 
73
- Output Plugin can be used via match directive. Output Plugin assumes the input format as described above.
74
+ Output Plugin can send events to EverySense server. It can be used via match directive. Output Plugin assumes the input format as described above.
74
75
 
75
76
  ```
76
77
  <match tag_name>
@@ -103,6 +104,63 @@ Output Plugin can be used via match directive. Output Plugin assumes the input f
103
104
  - **output_name**: sensor_name of the output sensor data.
104
105
  - **type_of_value**: type of value (default: Integer)
105
106
 
107
+ ## Filter Plugin (Fluent::EverySenseFilter)
108
+
109
+ Filter Plugin can split an EverySense Server event into multiple fluentd events if it has multiple data. It can be used via filter directive.
110
+
111
+ ```
112
+ <filter tag_name>
113
+ @type everysense
114
+ </filter>
115
+ ```
116
+
117
+ The following input data from EverySense Server will be splitted into multiple fluentd events.
118
+
119
+ ```
120
+ {"json":
121
+ [
122
+ { "farm_uuid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
123
+ "sensor_name":"collection_data_1",
124
+ "data_class_name":"Illuminance",
125
+ "data": {
126
+ "at":"2016-08-24 00:15:00 UTC",
127
+ "value":137.0,
128
+ "unit":"lx"
129
+ }
130
+ },
131
+ { "farm_uuid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
132
+ "sensor_name":"collection_data_2",
133
+ "data_class_name":"Location",
134
+ "data": {
135
+ "at":"2016-08-24 00:15:00 UTC",
136
+ "values":[138.442062,35.8162422,671.599975],
137
+ "unit":"degree"
138
+ }
139
+ }
140
+ ]
141
+ }
142
+ ```
143
+
144
+ ```
145
+ { "farm_uuid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
146
+ "sensor_name":"collection_data_1",
147
+ "data_class_name":"Illuminance",
148
+ "data": {
149
+ "at":"2016-08-24 00:15:00 UTC",
150
+ "value":137.0,
151
+ "unit":"lx"
152
+ }
153
+ },
154
+ { "farm_uuid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
155
+ "sensor_name":"collection_data_2",
156
+ "data_class_name":"Location",
157
+ "data": {
158
+ "at":"2016-08-24 00:15:00 UTC",
159
+ "values":[138.442062,35.8162422,671.599975],
160
+ "unit":"degree"
161
+ }
162
+ }
163
+ ```
106
164
 
107
165
  ## Contributing
108
166
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-everysense"
7
- spec.version = "0.0.5"
7
+ spec.version = "0.0.6"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = '>= 2.0.0'
21
+ spec.required_ruby_version = '>= 2.1.0'
22
22
 
23
- spec.add_dependency 'fluentd', '>= 0.10.0'
23
+ spec.add_dependency 'fluentd', '~> 0.12.0'
24
+ #spec.add_dependency 'fluentd', '>= 0.10.0'
24
25
 
25
26
  spec.add_development_dependency "bundler", "~> 1.10"
26
27
  spec.add_development_dependency "rake", "~> 10.0"
@@ -0,0 +1,27 @@
1
+ module Fluent
2
+ # EverySenseFilter
3
+ # Split EverySense data into multiple output entries
4
+ # to store each datum separately
5
+ class EverySenseFilter < Filter
6
+ Plugin.register_filter('everysense', self)
7
+
8
+ def filter_stream(tag, es)
9
+ new_es = MultiEventStream.new
10
+ es.each do |time, record|
11
+ # puts "filter_everysense: #{record}"
12
+ split(time, record, new_es)
13
+ end
14
+ new_es
15
+ end
16
+
17
+ private
18
+
19
+ def split(time, record, new_es)
20
+ if record[:json].instance_of?(Array)
21
+ record[:json].each { |r| new_es.add(time, r) }
22
+ else
23
+ new_es.add(time, record)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -66,7 +66,7 @@ module Fluent
66
66
  end
67
67
 
68
68
  desc 'Tag name assigned to inputs'
69
- config_param :tag, :string, :default => nil # TODO: mandatory option
69
+ config_param :tag, :string, :default => 'everysense'
70
70
  desc 'Polling interval to get message from EverySense API'
71
71
  config_param :polling_interval, :integer, :default => 60
72
72
  desc 'Device ID'
@@ -91,7 +91,7 @@ module Fluent
91
91
  end
92
92
 
93
93
  def start
94
- raise StandardError.new if @tag.nil?
94
+ #raise StandardError.new if @tag.nil?
95
95
  super
96
96
  start_proxy
97
97
  @proxy_thread = Thread.new do
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-everysense
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-15 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.0
19
+ version: 0.12.0
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
- version: 0.10.0
26
+ version: 0.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,7 @@ files:
66
66
  - Rakefile
67
67
  - fluent-plugin-everysense.gemspec
68
68
  - lib/fluent/plugin/everysense_proxy.rb
69
+ - lib/fluent/plugin/filter_everysense.rb
69
70
  - lib/fluent/plugin/in_everysense.rb
70
71
  - lib/fluent/plugin/out_everysense.rb
71
72
  - tutorial/ja/json_over_http_api_tutorial.md
@@ -81,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
82
  requirements:
82
83
  - - ">="
83
84
  - !ruby/object:Gem::Version
84
- version: 2.0.0
85
+ version: 2.1.0
85
86
  required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - ">="