class Blazer::Adapters::InfluxdbAdapter
Public Instance Methods
parameter_binding()
click to toggle source
# File lib/blazer/adapters/influxdb_adapter.rb, line 46 def parameter_binding # not supported end
preview_statement()
click to toggle source
# File lib/blazer/adapters/influxdb_adapter.rb, line 37 def preview_statement "SELECT * FROM {table} LIMIT 10" end
quoting()
click to toggle source
docs.influxdata.com/influxdb/v1.8/query_language/spec/#strings
# File lib/blazer/adapters/influxdb_adapter.rb, line 42 def quoting :backslash_escape end
run_statement(statement, comment)
click to toggle source
# File lib/blazer/adapters/influxdb_adapter.rb, line 4 def run_statement(statement, comment) columns = [] rows = [] error = nil begin result = client.query(statement, denormalize: false).first if result columns = result["columns"] rows = result["values"] # parse time columns # current approach isn't ideal, but result doesn't include types # another approach would be to check the format time_index = columns.index("time") if time_index rows.each do |row| row[time_index] = Time.parse(row[time_index]) if row[time_index] end end end rescue => e error = e.message end [columns, rows, error] end
tables()
click to toggle source
# File lib/blazer/adapters/influxdb_adapter.rb, line 33 def tables client.list_series end
Protected Instance Methods
client()
click to toggle source
# File lib/blazer/adapters/influxdb_adapter.rb, line 52 def client @client ||= InfluxDB::Client.new(url: settings["url"]) end