Help us understand the problem. What is going on with this article?

AWS IoT Device SDK for Ruby を使ってみた #5 - Influx DB構築

More than 3 years have passed since last update.

// 当記事は, 以下親記事の Setup Flowの一部です.
// AWS IoT Device SDK for Ruby を使ってみた

以下, 参考とさせて頂きました. 有難うございます.
http://qiita.com/akito1986/items/9c1c14a36654646db456

環境

  • ubuntu on AWS ec2
  • InfluxDB and Chronograph

Influxdb

Install

https://docs.influxdata.com/influxdb/v1.0/introduction/installation/

console
sudo apt-get update
sudo apt-get upgrade
console
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
console
sudo apt-get update && sudo apt-get install influxdb
sudo service influxdb start

Create database

https://docs.influxdata.com/influxdb/v1.0/introduction/getting_started/

console
// DB nameは任意

$ influx
CREATE DATABASE sensorMeasure_sendai_test
CREATE DATABASE my_db

Create user

// user name, passwordは任意

$ influx
CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES

Edit config

console
sudo vim /etc/influxdb/influxdb.conf
/etc/influxdb/influxdb.conf
[http]
-  auth-enabled = false
+  auth-enabled = true
console
sudo /etc/init.d/influxdb restart

// login comannd sample (以降は, user認証が必要となる)
influx -username admin -password admin

Test write and show Data

https://docs.influxdata.com/influxdb/v1.0/guides/writing_data/
https://docs.influxdata.com/influxdb/v1.0/tools/api/

  • post data

    console
    $ curl -i -X POST http://52.197.142.78:8086/write?db=my_db -u admin:admin --data-binary  'cpu_load_short,host=server01,region=us-west value=0.75'
    us-west value=0.75'
    
    HTTP/1.1 204 No Content
    Content-Type: application/json
    Request-Id: 7015c2a7-900a-11e6-8009-000000000000
    X-Influxdb-Version: 1.0.2
    Date: Tue, 11 Oct 2016 23:28:38 GMT
    
  • show data

    console
    $ curl -X GET 'http://52.197.142.78:8086/query?q=select+*+from+cpu_load_short%3B&db=my_db' -u admin:admin
    
    {"results":[{"series":[{"name":"cpu_load_short","columns":["time","host","region","value"],"values":[["2016-10-11T23:22:16.50324883Z","server01"]}]}]}
    

Data取得状況を確認

既に, Raspberry pi | AWS IoT | AWS Lambda | Influx と流れ, DBへ値が保存されているはずです.

認証

  • http://[Host or IP]:8083 を開く
  • DB user name, pass を入力
  • [Save] を選択 スクリーンショット 2016-10-12 9.50.51.png

温度/湿度 取得

  • 右上の pull down から, 使用する DB名を選択 (ここでは, sensorMeasure_sendai_test)
    スクリーンショット 2016-10-12 9.52.58.png


  • [select * from DHT11Measure;] を入力.

  • 温度/湿度値が表示されます.
    スクリーンショット 2016-10-12 9.59.13.png


以上.
次に最終工程の, #6 - Chronograph にて可視化 へ.

Satoshi_Numasawa
サムネイル引用元はこちら. https://www.pixiv.net/en/users/1007401
ruby-dev
Ruby開発はRuby on Railsをコア技術とし、Web系から基幹系まで多様な開発に携わっています。
https://www.ruby-dev.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away