class InfluxRemix::Writer
Public Class Methods
new(host, org, bucket, token)
click to toggle source
# File lib/influx_remix/writer.rb, line 5 def initialize(host, org, bucket, token) @url = host @org = org @bucket = bucket @token = token end
Public Instance Methods
write(data)
click to toggle source
# File lib/influx_remix/writer.rb, line 12 def write(data) stringData = data.reduce("") do |blob, line| blob + line.line_protocol + "\n" end conn = Faraday.new( url: @url, params: {org: @org, bucket: @bucket}, headers: {"Authorization" => "Token #{@token}"} ) res = conn.post('api/v2/write') do |req| req.body = stringData.chomp end end