fluent-plugin-everysense 0.0.6 → 0.0.7

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: 71732bc5a744276424c6081b7aa3c5b0c0ac9a80
4
- data.tar.gz: e0a0cf71e1db33a9556b28b67861cd85ccb5d098
3
+ metadata.gz: 2c47e532dfd4ce2294d6cd5df989342922b83004
4
+ data.tar.gz: 7d88128bf365d6ad28b62a712508c8ead55e3519
5
5
  SHA512:
6
- metadata.gz: 0b2280bab8f9d46c6ce0f76ce449df84d4bba414897a4a83e15da9137d1254252d9234356bbd51d99db8c86c188eaada473f21dddcba499c896c3168009964c8
7
- data.tar.gz: 079d63d4938f6c8c28f53db240c11accaa20d18cf207205ec02921b142c5a6281f7d3aaf8fa2be6615f9d9a7ea5f94855f9a7097512c590db6715b2fe4d4bdd8
6
+ metadata.gz: ef5128c21c0355240721c01ed4eb9c0761f520af29ed40f4341ae8c25a917c98f8876393e9506c3ab0d5b3af7bc3b7661349b026af629b9d8cc8076319187f6c
7
+ data.tar.gz: 600400a7606d61478a0f35a44be298eca60598cb96e241c7027cfce3554e64982d9b3fa1269b92d9baaaf5b0de184e0f795bad58a0be2e539b690af48e3151c5
@@ -0,0 +1,87 @@
1
+ # EveryStampおよびEveryPostのデータ蓄積
2
+
3
+ ここではfluentd (fluent-plugin-everysense, fluent-plugin-elasticsearch) を用いて,EverySenseサーバから取得したデータをElasticSearchに蓄積し,Kibanaで可視化する事例を紹介します.
4
+
5
+
6
+ ## ElasticSearchおよびKibanaのセットアップ
7
+
8
+ ElasticSearchについて,詳細はElasticSearchのページをご参照ください.
9
+
10
+ https://www.elastic.co/downloads/elasticsearch
11
+
12
+ Linuxの場合は以下のページにある方法でパッケージ管理システム (apt, yum) を用いてインストールするのが簡単です.
13
+
14
+ https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html
15
+
16
+ Kibanaも同様にパッケージ管理システムを用いてインストールできます.
17
+
18
+ https://www.elastic.co/guide/en/kibana/4.5/_upgrading_kibana.html
19
+
20
+ インストールが完了したらサービスを開始します.
21
+
22
+ ```
23
+ sudo /bin/systemctl daemon-reload
24
+ sudo /bin/systemctl enable elasticsearch.service
25
+ sudo /bin/systemctl start elasticsearch.service
26
+ sudo /bin/systemctl enable kibana.service
27
+ ```
28
+
29
+ ブラウザで http://localhost:5601/ にアクセスするとKibanaの画面が表示されます.
30
+
31
+
32
+ ## fluentd のセットアップ
33
+
34
+ fluentdのインストールにはRubyが必要です.
35
+
36
+ ```
37
+ ### rbenvのインストール
38
+ sudo mkdir /usr/local/rbenv
39
+ sudo chown your_account:your_account_group /usr/local/rbenv
40
+ git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv
41
+ cd /usr/local/rbenv && src/configure && make -C src
42
+ echo 'export PATH="/usr/local/rbenv/bin:$PATH"' >> ~/.bashrc
43
+ echo 'export RBENV_ROOT="/usr/local/rbenv"' >> ~/.bashrc
44
+ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
45
+ source ~/.bashrc
46
+ ### ruby-buildのインストール
47
+ git clone https://github.com/rbenv/ruby-build.git /usr/local/rbenv/plugins/ruby-build
48
+ ### rubyのインストール
49
+ rbenv install 2.2.4
50
+ rbenv global 2.2.4
51
+ ```
52
+ 以下fluentdと必要なpluginのインストールです.
53
+
54
+ ```
55
+ ### fluentdのインストール
56
+ gem install fluent-plugin-everysense fluent-plugin-elasticsearch
57
+ ```
58
+
59
+ fluent-plugin-everysense は現状 fluentd のバージョン0.12.xに依存しているため,fluent-plugin-everysenseを先にインストールし,fluentd の 0.12.x をインストールします.0.14.x 系への対応は今後の課題です.
60
+
61
+
62
+ ## ElasticSearchでのmappingの作成
63
+
64
+ piot-mapping.json ファイルを用いてmappingを作成します.
65
+
66
+ ```
67
+ curl -XPUT 'http://localhost:9200/piot'
68
+ cat piot-mapping.json | curl -XPUT 'http://192.168.23.1:9200/piot/everystamp/_mapping' -d @-
69
+ ```
70
+
71
+ KibanaのSettingsのindex nameとしてpiotを指定し,時間属性としてtimestampを指定して,index patternを作成します.
72
+
73
+
74
+ ## fluentdの設定
75
+
76
+ fluent-everystamp.conf ファイルを用いてfluentdを立ち上げます.
77
+
78
+ ```
79
+ fluentd -c fluent-everystamp.conf
80
+ ```
81
+
82
+ これでEverySense ServerにアップロードされたデータをElasticSearchに格納できるようになりました.
83
+
84
+ fluentdをデーモンとして起動する方法については以下のページなどを参照してください.
85
+
86
+ "fluentdをsystemdで管理する" (matetsuだもんで)
87
+ http://matetsu.hatenablog.com/entry/2015/12/08/015444
@@ -0,0 +1,70 @@
1
+ <source>
2
+ # fluent-plugin-everysense の input plugin を指定します.
3
+ @type everysense
4
+ # ここではラベルを用いていますが,tagを用いることもできます.
5
+ @label @test
6
+ # EverySense Serverのアカウント名を指定してください.
7
+ login_name username
8
+ # EverySense Serverのアカウントパスワードを指定してください.
9
+ password XXXXXXXXXXXX
10
+ # EverySense Server上に作成したレシピのレシピIDを指定してください.
11
+ recipe_id XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
12
+ # 取得間隔は変更可能です.
13
+ polling_interval 30
14
+ # 現状JSONフォーマットのみ対応しています.
15
+ format json
16
+ </source>
17
+
18
+ <label @test>
19
+ # fluent-plugin-everysense の filter plugin で複数センサの情報を同時に取得した場合にfluentd上の複数イベントに変換します.
20
+ <filter **>
21
+ @type everysense
22
+ </filter>
23
+ # EverySense Serverの出力をElasticSearchのmappingの形式に変換します.
24
+ # センサごとの変換ロジックが必要ですが,ここではEveryStamp, EveryPostで
25
+ # 利用可能なセンサについて変換例を示しています.
26
+ <filter **>
27
+ @type record_transformer
28
+ enable_ruby true
29
+ auto_typecast true
30
+ <record>
31
+ timestamp ${Time.parse(data["at"]).utc.strftime("%Y-%m-%d %H:%M:%S")}
32
+ accelerometer ${if data_class_name == "Accelerometer" then return {"x": data["values"][0], "y": data["values"][1], "z": data["values"][2]} end}
33
+ air_hygrometer ${if data_class_name == "AirHygrometer" then return data["value"] end}
34
+ air_temperature ${if data_class_name == "AirTemperature" then return data["value"] end}
35
+ angular_velocity ${if data_class_name == "AngularVelocity" then return {"x": data["values"][0], "y": data["values"][1], "z": data["values"][2]} end}
36
+ barometric_pressure ${if data_class_name == "BarometricPressure" then return data["value"] end}
37
+ environmental_sound ${if data_class_name == "EnvironmentalSound" then return data["values"] end}
38
+ earth_magnetometer ${if data_class_name == "EarthMagnetometer" then return {"x": data["values"][0], "y": data["values"][1], "z": data["values"][2]} end}
39
+ illuminance ${if data_class_name == "Illuminance" then return data["value"] end}
40
+ location ${if data_class_name == "Location" then if data["location"].nil? then return {"lon": data["values"][0], "lat": data["values"][1]} else return {"lon": data["location"]["longitude"], "lat": data["location"]["latitude"]} end end}
41
+ motion_activity ${if data_class_name == "MotionActivity" then return data["value"] end}
42
+ switch ${if data_class_name == "Switch" then if data["value"] == "true" then return true else return false end end}
43
+ uv_figure ${if data_class_name == "UV_Figure" then return data["value"] end}
44
+ </record>
45
+ </filter>
46
+ # デバッグ用に標準出力だけで確認したい場合は以下を有効にしてください.
47
+ #<match **>
48
+ # @type stdout
49
+ #</match>
50
+ # ElasticSearchに格納しながら,標準出力でも格納された内容を確認したい
51
+ # 場合は,以下でコメントアウトされている箇所を有効にしてください.
52
+ <match **>
53
+ #@type copy
54
+ #<store>
55
+ @type elasticsearch
56
+ # ElasticSearchを立ち上げたホストを指定してください.
57
+ host localhost
58
+ port 9200
59
+ index_name piot
60
+ type_name everystamp
61
+ logstash_format false
62
+ include_tag_key true
63
+ time_key data.at
64
+ flush_interval 30s
65
+ #</store>
66
+ #<store>
67
+ # @type stdout
68
+ #</store>
69
+ </match>
70
+ </label>
@@ -0,0 +1,123 @@
1
+ {
2
+ "everystamp": {
3
+ "properties": {
4
+ "farm_uuid": {
5
+ "type": "string"
6
+ },
7
+ "sensor_name": {
8
+ "type": "string"
9
+ },
10
+ "data_class_name": {
11
+ "type": "string"
12
+ },
13
+ "timestamp": {
14
+ "type": "date",
15
+ "format": "yyyy-MM-dd HH:mm:ss"
16
+ },
17
+ "data": {
18
+ "type": "nested",
19
+ "properties": {
20
+ "at": {
21
+ "type": "string"
22
+ },
23
+ "unit": {
24
+ "type": "string"
25
+ },
26
+ "value": {
27
+ "type": "string"
28
+ },
29
+ "values": {
30
+ "type": "string"
31
+ },
32
+ "location": {
33
+ "type": "nested",
34
+ "properties": {
35
+ "latitude": {
36
+ "type": "double"
37
+ },
38
+ "longitude": {
39
+ "type": "double"
40
+ },
41
+ "elevation": {
42
+ "type": "double"
43
+ },
44
+ "datum": {
45
+ "type": "string"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ },
51
+ "accelerometer": {
52
+ "type": "nested",
53
+ "properties": {
54
+ "x": {
55
+ "type": "double"
56
+ },
57
+ "y": {
58
+ "type": "double"
59
+ },
60
+ "z": {
61
+ "type": "double"
62
+ }
63
+ }
64
+ },
65
+ "air_hygrometer": {
66
+ "type": "double"
67
+ },
68
+ "air_temperature": {
69
+ "type": "double"
70
+ },
71
+ "angular_velocity": {
72
+ "type": "nested",
73
+ "properties": {
74
+ "x": {
75
+ "type": "double"
76
+ },
77
+ "y": {
78
+ "type": "double"
79
+ },
80
+ "z": {
81
+ "type": "double"
82
+ }
83
+ }
84
+ },
85
+ "barometric_pressure": {
86
+ "type": "double"
87
+ },
88
+ "environmental_sound": {
89
+ "type": "double"
90
+ },
91
+ "earth_magnetometer": {
92
+ "type": "nested",
93
+ "properties": {
94
+ "x": {
95
+ "type": "double"
96
+ },
97
+ "y": {
98
+ "type": "double"
99
+ },
100
+ "z": {
101
+ "type": "double"
102
+ }
103
+ }
104
+ },
105
+ "illuminance": {
106
+ "type": "double"
107
+ },
108
+ "location": {
109
+ "type": "geo_point",
110
+ "lat_lon": true
111
+ },
112
+ "motion_activity": {
113
+ "type": "string"
114
+ },
115
+ "switch": {
116
+ "type": "boolean"
117
+ },
118
+ "uv_figure": {
119
+ "type": "double"
120
+ }
121
+ }
122
+ }
123
+ }
@@ -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.6"
7
+ spec.version = "0.0.7"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-everysense
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
@@ -64,6 +64,9 @@ files:
64
64
  - LICENSE
65
65
  - README.md
66
66
  - Rakefile
67
+ - examples/everystamp/README.md
68
+ - examples/everystamp/fluent-everystamp.conf
69
+ - examples/everystamp/piot-mapping.json
67
70
  - fluent-plugin-everysense.gemspec
68
71
  - lib/fluent/plugin/everysense_proxy.rb
69
72
  - lib/fluent/plugin/filter_everysense.rb