Project

memoir

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Client library for easy communication with OpenTSDB
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
>= 0
~> 0.36
~> 0.11

Runtime

 Project Readme

Memoir

Ruby client library for easy communication with OpenTSDB v2.2+

Build Status Dependency Status Gem Version Code Climate

Installation

Add this line to your application's Gemfile:

gem 'memoir'

And then execute:

$ bundle

Or install it yourself as:

$ gem install memoir

Usage example

Memoir classes and attributes loosely follow the OpenTSDB query api described here: http://opentsdb.net/docs/build/html/api_http/query/index.html

# Create a 'literal_or' filter for tag 'hostname' matching any of values 'some.host1', 'some.host2' and 'some.host3' without grouping
filter = Memoir::Filter.new Memoir::FilterType::LITERAL_OR, 'hostname', 'some.host1|some.host2|some.host3', false
# Create a query for metric 'some.important.metric' with aggregator 'sum'
query = Memoir::Query.new Memoir::Aggregator::SUM, 'some.important.metric'
# Create a downsample per one day with aggregator 'avg'
downsample = Memoir::Downsample.new Memoir::TimePeriod.new(1, Memoir::Units::DAYS), Memoir::Aggregator::AVG
query.downsample = downsample
# Add filter to the query
query << filter
# Create a request for data from one month ago till now (default value for no end time)
request = Memoir::Request.new Memoir::TimePeriod.new(1, Memoir::Units::MONTHS)
# Add query to the request
request << query
# Initialize client
client = Memoir::Client.new 'http://opentsdb.host.org', 4242
# Dry running a request will print a request body in JSON format
client.dry_run request
# Run request
response = client.run request

puts response.status
puts response.data_sets.first.dps unless response.data_sets.empty?

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Misenko/memoir.