Class: Hallmonitor::Outputters::Influxdb
- Inherits:
-
Hallmonitor::Outputter
- Object
- Hallmonitor::Outputter
- Hallmonitor::Outputters::Influxdb
- Defined in:
- lib/hallmonitor/outputters/influxdb.rb
Overview
An outputter for InfluxDB
Defined Under Namespace
Classes: EventData
Constant Summary collapse
- PRECISION_MAP =
Maps Influxdb client precisions to multipliers for Time#to_r to get the value to send to influxdb for the timestamp
{ 'ns' => 10**9, 'u' => 10**6, 'ms' => 10**3, 's' => 1, 'm' => 1 / 60, 'h' => 1 / 3600 }.freeze
Instance Attribute Summary collapse
-
#transformer ⇒ #transform(Event, EventData)
Object used to transform data before it is sent to InfluxDB.
Attributes inherited from Hallmonitor::Outputter
Instance Method Summary collapse
-
#initialize(influxdb_client, tags: {}, transformer: nil) ⇒ Influxdb
constructor
Builds a new Influxdb outputter.
-
#process(event) ⇒ Object
Sends events to InfluxDB instance.
Constructor Details
#initialize(influxdb_client, tags: {}, transformer: nil) ⇒ Influxdb
Builds a new Influxdb outputter
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hallmonitor/outputters/influxdb.rb', line 40 def initialize(influxdb_client, tags: {}, transformer: nil) unless influxdb_client.respond_to?(:write_point) raise 'Supplied InfluxDB Client was not as expected' end if transformer && !transformer.respond_to?(:transform) raise 'Supplied transformer does not respond to :transform' end super('influxdb') @tags = {}.merge() @client = influxdb_client || raise('Must supply an InfluxDb client') @transformer = transformer @precision_mult = PRECISION_MAP[@client.config.time_precision || 's'] end |
Instance Attribute Details
Instance Method Details
#process(event) ⇒ Object
Sends events to InfluxDB instance
58 59 60 61 |
# File 'lib/hallmonitor/outputters/influxdb.rb', line 58 def process(event) event_data = build_event_data(event) transform_and_write(event, event_data) end |