module Legion::Extensions::Influxdb::Runners::Writer
Public Class Methods
write(series:, tags:, values:, host: 'localhost', port: 8086, database:, **_opts)
click to toggle source
# File lib/legion/extensions/influxdb/runners/writer.rb, line 4 def self.write(series:, tags:, values:, host: 'localhost', port: 8086, database:, **_opts) client = InfluxDB::Client.new(database, host: host, port: port) {} end
write_points(metrics:, host: 'localhost', port: 8086, database: 'telegraf', time_precision: 'ms', **_opts)
click to toggle source
# File lib/legion/extensions/influxdb/runners/writer.rb, line 9 def self.write_points(metrics:, host: 'localhost', port: 8086, database: 'telegraf', time_precision: 'ms', **_opts) settings[:client] ||= InfluxDB::Client.new(database, host: host, port: port, async: false) metrics = Legion::JSON.load(metrics) if metrics.is_a? String if metrics[:timestamp].nil? metrics[:timestamp] = Time.now.to_i time_precision = 's' end settings[:client].write_point('sensors', metrics, time_precision) {} end