opentsdb-ruby
Ruby client for OpenTSDB HTTP Query API.
Installation
Add this line to your application's Gemfile:
gem 'opentsdb-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install opentsdb-ruby
Quick Start Guide
Configure opentsdb
#config/initializers/opentsdb.rb
Opentsdb.configure do |config|
config.host = 'localhost' # opentsdb server host default: localhost
config.port = 4242 # opentsdb server port default: 4242
end
Usage
# define simple query params
params = { begin: Time.now.ago(1.hour), q: 'avg:system.load.1{host=*}' }
# opensted
client = Opentsdb::Client.new(params)
result = client.query # opentsdb json result
# complicate query params
params = { begin: Time.now.ago(1.hour), end: Time.now, q: 'avg:system.load.1{host=server1, host=server2, tagk=tagv}by{host}', interval: 360 }
client = Opentsdb::Client.new(params)
result = client.query # opentsdb json result
# reconfig opentsdb host port
params = { host: '192.168.0.100', port: 8000, q: 'avg:system.load.1{host=*}' }
client = Opentsdb::Client.new(params)
result = client.query # opentsdb json result
