Project

slate

0.01
No commit activity in last 3 years
No release in over 3 years
Simple api on top of the graphite render api
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6.3
>= 0
>= 0
>= 0

Runtime

~> 0.8
~> 1.7
~> 1.4
 Project Readme

Slate

Build Status Dependency Status Coverage Status Code Climate Bitdeli Badge

Simple wrapper to the Graphite render api

Installation

Add this line to your application's Gemfile:

gem 'slate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slate

Usage

Configuration

Configure the Slate client

client = Slate.configure do |config|
  config.endpoint = "http://your.graphite-server.com"
  config.timeout  = 30 # In seconds (default: 10)
end

Ruby interface

To build a basic graph

graph = Slate::Graph.new(client)
graph << Slate::Target.build("stats.web01.load")

puts graph.url
puts graph.download(:json)

Adjust the timeframe of the graph

graph       = Slate::Graph.new(client)
graph.from  = "-1w"
graph.until = "-1d"
graph << Slate::Target.build("stats.web01.load")

Use functions

graph = Slate::Graph.new(client)

graph << Slate::Target.build("stats.web01.load") do |target|
  target.add_function :sum
  target.add_function :alias, "load"
end

Or more complex targets (like passing targets to other targets): Graph Spec

Slate text interface

Slate also provides a text interface for building targets, this can be useful if you want to enable users to create graphs. This text interface also support being able to pass targets as arguments to functions, like you need for the asPercentOf function.

graph = Slate::Graph.new(client)

target = <<-SLATE
"stats.web1.load" {
  sum
  alias "load"
}
SLATE

graph << Slate::Parser.parse(target)

Full test cases for different things this syntax supports are here: Parser Spec

Calculations

Slate supports things call Calculations, which take in graphite data and boil them down to single numbers, this can be useful if you wanted to calculate the average load over the week for all your servers.

graph = Slate::Graph.new(client)
graph << Slate::Target.build("stats.web01.load")

p Slate::Calculation::Mean.new(graph).result
# [{ "name" => "stats.web01.load", "value" => 1.5 }]

All the possible calculation classes are here.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contributors

Trae Robrock (https://github.com/trobrock)

Andrew Katz (https://github.com/andrewkatz)

David Sennerlöv (https://github.com/dsennerlov)