Class: Linr::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/linr/client.rb

Overview

Simple UDP-based InfluxDB client

Examples:

client = Client.new(host: "127.0.0.1", port: 8063)
client.write(
  measurement: "cpu_load_short",
  tags: { host: "server01", region: "us-west" },
  fields: { value: 0.64 },
  timestamp: 1434055562
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Initialize a new client.

Parameters:

  • opts (Hash) (defaults to: {})

    See Linr::Config for opts

See Also:


17
18
19
20
# File 'lib/linr/client.rb', line 17

def initialize(opts = {})
  @config = Config.new(opts)
  connect!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


12
13
14
# File 'lib/linr/client.rb', line 12

def config
  @config
end

Instance Method Details

#write(*series) ⇒ Object

Write one or more series to the InfluxDB connection

Parameters:

  • series (Array<Hash>)

    see Data for values


24
25
26
27
# File 'lib/linr/client.rb', line 24

def write(*series)
  payload = build_payload(series)
  send(payload)
end