Riemann Ruby Client
Installing
gem install riemann-client
Use
require 'riemann/client'
c = Riemann::Client.new host: 'localhost', port: 5555, timeout: 5
c << {service: 'testing', metric: 2.5}
c << {
host: 'web3',
service: 'api latency',
state: 'warn',
metric: 63.5,
description: "63.5 milliseconds per request",
time: Time.now.to_i - 10
}
c << {host: nil, service: 'the cloud', state: 'nebulous'}
c['true']
c['host =~ "%.dc1" and (state = "critical" or state = "warning")']
Transports
Riemann::Client sends small events over UDP by default, and uses TCP for
queries and large events. UDP sends are essentially "shouting into the void".
They will not block your application and are roughly an order of magnitude
faster than TCP, but you will not know if the server is down or encountered an
error. You can specify what transport to use by selecting a subclient:
c.udp << { :state => "ok" }
c.tcp << { :state => "ok" }
c.tcp["true"]
c.udp["true"]
Client state management
Riemann::Client provides some classes to make managing state updates easier.
Riemann::MetricThread starts a thread to poll a metric periodically, which can
be used to flush an accumulated value to ustate at regular intervals.
Riemann::AutoState bundles a state and a client together. Any changes to the
AutoState automatically send the new state to the client.
License
The MIT License
Copyright (c) 2011-2022 Kyle Kingsbury