fluent-plugin-festival 0.0.9 → 0.0.10
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/examples/README.md +4 -4
- data/examples/fluent-festival.conf +5 -3
- data/examples/{train_station-mapping.json → iot_gateway-mapping.json} +4 -1
- data/fluent-plugin-festival.gemspec +1 -1
- data/lib/fluent/plugin/festival_proxy.rb +24 -2
- data/lib/fluent/plugin/in_festival.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bf3cd0a66259715fde049cd5f12090c51742288
|
4
|
+
data.tar.gz: 005bf5cdf8a890ca3df7c2bf4bb96e9073de13a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
74
|
+
vi iot_gateway-mapping.json
|
75
75
|
---
|
76
76
|
{
|
77
|
-
"
|
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/
|
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
|
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
|
-
#<
|
29
|
-
#
|
30
|
-
|
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
|
@@ -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
|
-
|
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.
|
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-
|
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/
|
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
|