At Mailprotector we recently integrated batsd with our graphite statistics and metrics system. The result is a faster and native interface for querying our metrics data using ruby. This change has made it easy for us to create our own dashboards and reports in our Rails apps. Since batsd was built with compatibility for statsd, integrating was simple. Using the repeater option for statsd, we are able to continue to send the data to graphite but also repeat it to our batsd system. Here is an example of the repeater configuration.
Now we have the data in two places. We can also optimize the retention in batsd for our needs there and keep using graphite setup the way it was.
The Batsd Client Gem
We needed a client to query the data from batsd for our dashboards and reports we wanted to build in our internal Rails apps. There is an example ruby client provided in the batsd repository but nothing packaged up and ready to go. So using that example as a starting point, I created a batsd ruby client and bundled it up as a gem.
It’s a simple gem installation.
Or you can include it in your Gemfile.
You can connect to Batsd by instantiating the Batsd class:
This assumes Batsd was started with a default configuration, and it listening on `localhost`, port `8127`. If you need to connect to a remote server or a different port, pass in the appropriate options:
The options and defaults are:
Now you can grab the list of available keys:
To pull the stats for a key:
Each stat is returned as a hash with a
:value. To pull only the timestamps or values for a range:
Pull requests are always welcome. Just fork the project.