fluent-plugin-festival 0.0.9 → 0.0.10

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: 1f7ff2033cb17a3eed91120e367c628170b6303e
4
- data.tar.gz: ab5990ecf2a5277b29768e3e9de483455ca99ed6
3
+ metadata.gz: 6bf3cd0a66259715fde049cd5f12090c51742288
4
+ data.tar.gz: 005bf5cdf8a890ca3df7c2bf4bb96e9073de13a4
5
5
  SHA512:
6
- metadata.gz: bd45aa3604f41f4264276e5b2fe263838a35992c08f9daf233a857c13326e9bcbad71f23cd3e5a126249fff5a797efd2dcdefd5b302c48b8cb37e4e6021455a1
7
- data.tar.gz: 46efde3496d336fb907c43106f5bb0a28b8a729a45cd8222393194717d8bf4e2b232f9bf9601f2386b6a33dd11b05ef7b0c5b81bf1fa0106ed4a521b20fa0daf
6
+ metadata.gz: b78c51d789fb7b6c7b2a956a1572475ccc4a50debc7ee86e71132174e1db7e8527960761c258bde02c8dc963a2bcc5bc36254d65a12a963e0c29b564bc7e15bf
7
+ data.tar.gz: 422e63db0875501548d441e1079490bd13b21dd618009fd85d816e21c889b2f6851d3bafed391694cdfff89bedf6ba71dffec6a0b2ab10812005d822a18a80e7
data/examples/README.md CHANGED
@@ -71,10 +71,10 @@ In the followings, how to store FESTIVAL platform data into Elasticsearch will b
71
71
  First of all, you need to create mapping in Elasticsearch. An Elasticsearch server is assumed to run in localhost.
72
72
 
73
73
  ```
74
- vi train_station-mapping.json
74
+ vi iot_gateway-mapping.json
75
75
  ---
76
76
  {
77
- "train_station": {
77
+ "iot_gateway": {
78
78
  "properties": {
79
79
  "timestamp": {
80
80
  "type": "date",
@@ -92,7 +92,7 @@ vi train_station-mapping.json
92
92
  ---
93
93
 
94
94
  curl -XPUT 'http://localhost:9200/festival'
95
- curl -XPUT 'http://localhost:9200/festival/train_station/_mapping' -d @train_station-mapping.json
95
+ curl -XPUT 'http://localhost:9200/festival/iot_gateway/_mapping' -d @iot_gateway-mapping.json
96
96
  ```
97
97
 
98
98
  ```
@@ -134,7 +134,7 @@ curl -XPUT 'http://localhost:9200/festival/train_station/_mapping' -d @train_sta
134
134
  host localhost
135
135
  port 9200
136
136
  index_name festival
137
- type_name train_station
137
+ type_name iot_gateway
138
138
  logstash_format false
139
139
  include_tag_key true
140
140
  time_key timestamp
@@ -25,9 +25,11 @@
25
25
  @label @test0
26
26
  </source>
27
27
 
28
- #<match *>
29
- # @type stdout
30
- #</match>
28
+ #<label @test0>
29
+ # <match *>
30
+ # @type stdout
31
+ # </match>
32
+ #</label>
31
33
 
32
34
  # <label> is not required in a simple use case like this configuration
33
35
  # You can just specify tag at filter and match directives
@@ -1,5 +1,5 @@
1
1
  {
2
- "train_station": {
2
+ "iot_gateway": {
3
3
  "properties": {
4
4
  "timestamp": {
5
5
  "type": "date",
@@ -10,6 +10,9 @@
10
10
  },
11
11
  "dataValue": {
12
12
  "type": "double"
13
+ },
14
+ "location": {
15
+ "type": "geo_point"
13
16
  }
14
17
  }
15
18
  }
@@ -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-festival"
7
- spec.version = "0.0.9"
7
+ spec.version = "0.0.10"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -99,7 +99,6 @@ module Fluent::Plugin
99
99
  def get_data_header
100
100
  {
101
101
  "Accept": "application/json",
102
- "x-nick-name": @email,
103
102
  "X-Auth-Token": @session["access_token"]
104
103
  }
105
104
  end
@@ -108,6 +107,28 @@ module Fluent::Plugin
108
107
  Pathname(path).basename.to_s
109
108
  end
110
109
 
110
+ def resource_path(path)
111
+ Pathname(path).dirname.to_s
112
+ end
113
+
114
+ def add_location(result, path)
115
+ if @require_location
116
+ log.debug "get_data (location): request #{get_data_request(resource_path(path))}, #{get_data_header.inspect}"
117
+ get_sensor_res = @https.get(get_data_request(resource_path(path)), get_data_header)
118
+ return result if !error_handler(get_sensor_res, "get_data failed.")
119
+ log.debug "get_data: #{get_sensor_res.body}"
120
+ sensor = JSON.parse(get_sensor_res.body)
121
+ # TODO: arbitrary geographicArea type should be supported
122
+ return result.merge({
123
+ "location": {
124
+ "lon": JSON.parse(sensor["location"]["geographicArea"])["coordinates"][0],
125
+ "lat": JSON.parse(sensor["location"]["geographicArea"])["coordinates"][1]
126
+ }
127
+ })
128
+ end
129
+ return result
130
+ end
131
+
111
132
  def get_data
112
133
  if !valid_session?
113
134
  return nil if create_session.nil?
@@ -123,10 +144,11 @@ module Fluent::Plugin
123
144
  get_data_res = @https.get(get_data_request(resource.path), get_data_header)
124
145
  next if !error_handler(get_data_res,"get_data failed.")
125
146
  log.debug "get_data: #{get_data_res.body}"
126
- data << {
147
+ result = {
127
148
  "resourceName": resource.path,
128
149
  "dataValue": JSON.parse(get_data_res.body)["dataValue"]
129
150
  }
151
+ data << add_location(result, resource.path)
130
152
  when "historical_data" then
131
153
  log.error "historical_data is not supported yet"
132
154
  next
@@ -21,6 +21,8 @@ module Fluent::Plugin
21
21
  config_param :tag, :string
22
22
  desc 'Polling interval to get message from FESTIVAL EaaS API'
23
23
  config_param :polling_interval, :integer, default: 60
24
+ desc 'Require sensor location'
25
+ config_param :require_location, :bool, default: false
24
26
 
25
27
  # <resoruce> tag can be used for specifying multiple resources in a <source> tag
26
28
  # If the user wants to specify different format or polling interval for each resource,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-festival
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-16 00:00:00.000000000 Z
11
+ date: 2017-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -79,7 +79,7 @@ files:
79
79
  - Rakefile
80
80
  - examples/README.md
81
81
  - examples/fluent-festival.conf
82
- - examples/train_station-mapping.json
82
+ - examples/iot_gateway-mapping.json
83
83
  - fluent-plugin-festival.gemspec
84
84
  - lib/fluent/plugin/festival_proxy.rb
85
85
  - lib/fluent/plugin/in_festival.rb