Upgrade to Pro — share decks privately, control downloads, hide ads and more …

InfluxDB: Making time series fun

InfluxDB: Making time series fun

Lindsay Holmwood

November 08, 2013
Tweet

More Decks by Lindsay Holmwood

Other Decks in Technology

Transcript

  1. # Verify pgrep -f -l influxdb 32333 /usr/bin/influxdb \ -pidfile

    /opt/influxdb/shared/influxdb.pid \ -config /opt/influxdb/shared/config.json # Manage sudo service influxdb stop sudo service influxdb start sudo service influxdb status
  2. #!/usr/bin/env ruby require 'rubygems' require 'influxdb' require 'json' database =

    "dev" name = "sine" influxdb = InfluxDB::Client.new("localhost", 8086, "auxesis", "foobarbaz", database)
  3. #!/usr/bin/env ruby require 'rubygems' require 'influxdb' require 'json' database =

    "dev" name = "sine" influxdb = InfluxDB::Client.new("localhost", 8086, "auxesis", "foobarbaz", database) loop do data = { :value => Value.next, } result = influxdb.write_point(name, data) sleep 1 end
  4. #!/usr/bin/env ruby require 'rubygems' require 'influxdb' require 'json' # Create

    an enumerator that emits a sine wave Value = (0..360).to_a.map {|i| Math.send(:sin, i / 10.0) * 10 }.each database = "dev" name = "sine" influxdb = InfluxDB::Client.new("localhost", 8086, "auxesis", "foobarbaz", database) loop do data = { :value => Value.next, } result = influxdb.write_point(name, data) sleep 1 end
  5. #!/usr/bin/env ruby require 'rubygems' require 'influxdb' require 'json' # Create

    an enumerator that emits a sine wave Value = (0..360).to_a.map {|i| Math.send(:sin, i / 10.0) * 10 }.each database = "dev" name = "sine" influxdb = InfluxDB::Client.new("localhost", 8086, "auxesis", "foobarbaz", database) loop do data = { :value => Value.next, } result = influxdb.write_point(name, data) if not (200..299).include?(result.code.to_i) p result exit 1 end sleep 1 end
  6. query = "select * from sine where time > now()

    - 1m;" q = CGI.escape(query)
  7. database = 'dev' query = "select * from sine where

    time > now() - 1m;" q = CGI.escape(query) username = 'auxesis' password = 'foobarbaz'
  8. database = 'dev' query = "select * from sine where

    time > now() - 1m;" q = CGI.escape(query) username = 'auxesis' password = 'foobarbaz' cmd = [] cmd << 'curl -s' cmd << "'http://localhost:8087/db/#{database}/series?u=#{username}&p=#{password}&q=#{q}'" command = cmd.join(' ') puts command system(command) puts
  9. [{"name":"k","columns":["time","sequence_number","value"],"points":[[1383889088856,970,-4.193609160732313], [1383889087853,969,-5.078965903906221],[1383889086850,968,-5.913575298651244], [1383889085848,967,-6.689098203780243],[1383889084846,966,-7.397785850778934], [1383889083843,965,-8.032557266939547],[1383889082839,964,-8.587070026099294], [1383889081837,963,-9.055783620066238],[1383889080834,962,-9.434014817545556], [1383889079832,961,-9.717984457438632],[1383889078829,960,-9.904855208971565], [1383889077825,959,-9.992759921366277],[1383889076823,958,-9.980820279793964], [1383889075820,957,-9.869155581206488],[1383889074809,956,-9.658881542360705], [1383889073805,955,-9.352099151945389],[1383889072803,954,-8.951873678196819], [1383889071800,953,-8.462204041751706],[1383889070797,952,-7.887982859754165],

    [1383889069792,951,-7.234947560442451],[1383889068788,950,-6.509623056662469], [1383889067786,949,-5.719256551095638],[1383889066783,948,-4.871745124605095], [1383889065780,947,-3.975556831214329],[1383889064777,946,-3.0396460881104708], [1383889063774,945,-2.0733642060675876],[1383889062767,944,-1.0863659542407975], [1383889061765,943,-0.08851309290403876],[1383889060762,942,0.9102241619984788], [1383889059759,941,1.8998667579543773],[1383889058756,940,2.8705265132772846], [1383889057753,939,3.8125049165494014],[1383889056750,938,4.7163900309419615], [1383889055747,937,5.573150535176614],[1383889054744,936,6.374225961502389], [1383889053741,935,7.1116122290598245],[1383889052738,934,7.777941618010928], [1383889051735,933,8.36655638536056],[1383889050732,932,8.87157528692351], [1383889049730,931,9.287952340772405],[1383889048727,930,9.611527245021165], [1383889047724,929,9.839066946186161],[1383889046721,928,9.968297942787993], [1383889045718,927,9.997929001426693],[1383889044715,926,9.92766405835907], [1383889043713,925,9.758205177669755],[1383889042710,924,9.491245536478946], [1383889041707,923,9.129452507276277],[1383889040704,922,8.676441006416674], [1383889039701,921,8.136737375071053],[1383889038698,920,7.515734153521483], [1383889037695,919,6.819636200681355],[1383889036692,918,6.05539869719601], [1383889035689,917,5.230657651576964],[1383889034686,916,4.353653603728932], [1383889033683,915,3.433149288198954],[1383889032681,914,2.478342079829598], [1383889031678,913,1.4987720966295235],[1383889030674,912,0.5042268780681123], [1383889029671,911,-0.4953564087836742]]}]
  10. database = 'dev' query = "select * from sine where

    time > now() - 1m;" q = CGI.escape(query) username = 'auxesis' password = 'foobarbaz' cmd = [] cmd << 'curl -s' cmd << "'http://localhost:8087/db/#{database}/series?u=#{username}&p=#{password}&q=#{q}'" cmd << '| jsonpp' command = cmd.join(' ') puts command system(command) puts
  11. [ { "name": "sine", "columns": [ "time", "sequence_number", "value" ],

    "points": [ [ 1383889204933, 1085, 0.9983341664682815 ], [ 1383889203929, 1084, 0 ], [ 1383889202193, 1083, -9.917788534431157 ], [ 1383889201190, 1082, -9.740490378683264 ] ] } ]