ç¨éçã«ã¯ä»¥åã«ãã£ã¦ã¿ãKibana/Elasticsearchã¨ãéè¤ããã¨ããã ãã©ãã¾ãè²ã ã®äºæ ã§ã
ã²ã¨ã¾ãç°å¢æ§ç¯+ãã¹ããã¼ã¿æå ¥+ã°ã©ãåã¾ã§ä½é¨ãã¦ã¿ãæãã§ã¯ç´æçã§åããããã好å°è±¡ã
ç°å¢æ§ç¯@Docker Compose
å人çã«ã¯ã馴æã¿Docker Composeã§ã
ã²ã¨ã¾ããã¼ã¿ãã¡ã¤ã«ã®é¡ã¯/srv/docker/grafana
以ä¸ã«ãã¦ã³ãããå½¢ã§éç´ããæ¹éã
ãã¼ãããã¡ã¤ã³ããã¹ã¯ã¼ããªããã¯é©æèªã¿æ¿ãã§ã
InfluxDBã®APIã«ããã8086ãã¼ãã«é¢ãã¦ã¯åãçªå·ãå²ãå½ã¦ã¦ãããæ¹ãåæã§æ¥½ã§ã¯ããã
version: "2" services: influxdb: image: influxdb volumes: - /srv/docker/grafana/influxdb:/var/lib/influxdb ports: - 8084:8083 #InfluxDBã®Web UI - 8086:8086 #InfluxDBã®HTTP API grafana: image: grafana/grafana ports: - 8085:3000 #grafanaã®ãã¼ã volumes: - /srv/docker/grafana/grafana:/var/lib/grafana environment: - GF_SERVER_ROOT_URL=http://192.168.77.6:8085 #æçµçã«ãªã¯ã¨ã¹ãããéã®URL - GF_SECURITY_ADMIN_PASSWORD=admin
ããã§docker-compose up -d
ã§ç«ã¡ä¸ããã¯ãã
ãã¼ã¿æå ¥
ã²ã¨ã¾ãä½ããããã¼ã¿ãå ¥ãã¦ã¿ãã
Rubyã§influxdb
ã¨ããgemããã£ã¦ãããã使ãã®ãç°¡åããã
以ä¸ã®ã¹ã¯ãªãããä½æãã¦ã¿ãã
create_db.rb
tutorial
ã¨ããååã®ãã¼ã¿ãã¼ã¹ãä½æã
#!/usr/bin/env ruby require 'influxdb' database = 'tutorial' influxdb = InfluxDB::Client.new host: '192.168.77.6' influxdb.create_database(database)
insert_data.rb
å
ã«ä½æããtutorial
ãã¼ã¿ãã¼ã¹ã«ãã¹ããã¼ã¿ã¨ãã¦ã©ã³ãã ãªå¤ãæã¤5è¦ç´ ã®ãã¼ã¿ãæå
¥ãã¦ããã
#!/usr/bin/env ruby require 'influxdb' host = '192.168.77.6' database = 'tutorial' time_precision = 's' influxdb = InfluxDB::Client.new database, :host => host, :time_precision => time_precision NAMES = ['test1', 'test2', 'test3', 'test4', 'test5'] NAMES.each do |name| data = { values: {value: rand(10000) + 1}, timestamp: Time.now.to_i } influxdb.write_point(name, data) end
ã°ã©ãåããã®ã§æéãéãã¦ä½åãå©ãã¦ããã
é¢åã§ããã°cronã«ã§ãä»è¾¼ãã§ããã¨è¯ããããããªãã
InfluxDBä¸ã§ç¢ºèª
InfluxDBã®Web UIãããæ°ãã«ãã¼ã¿ãã¼ã¹ãä½æããã¦ãããã¨ã¨ããã¼ã¿ãå ¥ã£ã¦ãã¦ãããã¨ã確èªã§ããã
Grafanaã§å¯è¦å
ãã¼ã¿ã½ã¼ã¹ã®ç»é²
ç»é¢å·¦ä¸ã®ã¢ã¤ã³ã³ã®ã¡ãã¥ã¼ãããã¼ã¿ã½ã¼ã¹ãé¸æããInfluxDBãã¤ãªãããã
ããã·ã¥ãã¼ãã®ä½æ
æ°ããªããã·ã¥ãã¼ããä½æããã°ã©ãã®è¦ç´ ãç»é²ãã¦ããã
ã¢ã¤ã³ã³é£ã®Homeã®ã¨ããããNewãã¿ã³ã§ããã·ã¥ãã¼ããä½æãã»ã»ã»
表示ã®ããã®è¡ãadd_row
ãã¿ã³ã§è¿½å ãã»ã»ã»
ã°ã©ãã®ããã®ã¯ã¨ãªãç»é²ãã¦ããã
ä¸ã¤ã®ã°ã©ãã«è¤æ°ã®è¦ç´ ã表示ã§ããã
æéãé¸æãã¦è¡¨ç¤ºã
ã°ã©ã以å¤ã®è¡¨ç¤ºæ¹æ³ãé¸æã§ããã
ï¼æ £ãããããããããªããã©ãï¼åã®Kibana/Elasticsearchã¯ããã¥ã¡ã³ããç®ãç¿ã®ããã«ãã¦è¿½ããªããããã£ã¦ãã®ã«æ¯ã¹ãã¨ã ããªãç´æçã§åãããããå°è±¡ããã£ãã
ä¾ãã°ãµã¼ãã¹ã®KPIãªããã¯å°ç¨ã®ç®¡çç»é¢ããã¡ãã¡ä½ãã®ããã£ãããããã§ã Fluentdã ã£ãããããããã«ã¸ã¥ã¢ã«ã«InfluxDBã«ãã¼ã¿ãæå ¥ãã¦ãã£ã¦ã ãããé©æããã·ã¥ãã¼ãã¨ãã¦ä½æãã¦å¯è¦åãããããªéç¨ãã§ããã幸ããããããªãã
æç³»åãã¼ã¿ãã¼ã¹ ã¨ãã¦ã®ç¹æ§ãªããã¯ã¾ã å ¨ç¶æ¼ããããã¦ããªãã¨ãããªã®ã§ã ããããåå¼·ãã¦ããããã¨ããã
- åºç社/ã¡ã¼ã«ã¼: æè¡è©è«ç¤¾
- çºå£²æ¥: 2014/08/14
- ã¡ãã£ã¢: Kindleç
- ãã®ååãå«ãããã°ãè¦ã