Välj en sida

Introduction

Hi, I’m Robin Chowdhury and I’ve been a part of Bonnier Broadcasting for five months now. I’m a member of the Integration team, we build services that other teams in Bonnier Broadcasting uses to do things like user authentication and getting movies and series recommendations. Most of our services are written in either Elixir or Go and our main way of doing development is through mob programming which has become my preferred way of doing software development. This time I got the chance to work mostly solo on a small tool that we found useful and open source it. It’s my first open source project of which I’m the main contributor. This post is about what problem the tool solves and how it solves it.

Moving matter through Space

We are using Heroku as our hosting platform for a lot of our services that we in the integration team are developing. To monitor our services we use the Librato add-on on Heroku. Librato gives us a quick and easy way to plot charts based on metrics so that we can make sure that no shenanigans are happening with our services. The add-on also includes some useful pre-made Librato Spaces (a Space is a dashboard with a collection of charts) that helps us monitor things like HTTP-status codes and app availability. We can also create custom made Spaces, charts and metrics to monitor more service specific things.

Each service on Heroku get its own Librato account and this is where we encountered a problem. We couldn’t find an easy way to copy our custom made Spaces with its charts and metrics from one Librato account to another. There are several cases where we would like to do so. The case that triggered this project was that we wanted to move a service from Heroku’s Common Runtime to a Heroku Private Space (not to be confused with a Librato Space) and doing so without loosing our Librato Spaces. Another case is when we have a service on stage and want to copy the custom made Librato Spaces to the production version or vice versa.

We found a third-party open source solution that looked promising. But while trying it we noticed that it would only work if the metrics already existed in the new Librato account making it not ideal for our use cases. After some more searching we decided that we would create our own solution.

Introducing CubaLibrato

CubaLibrato is a tool written in Elixir that was created to copy a Librato Space from one Librato account to another. It does so by downloading all charts from the source Librato Space through the Librato API. Through those charts it can extract the relevant metrics, remove the pre-made metrics created by the Librato add-on and then upload the metrics to the destination Librato Space. After uploading the metrics it can then upload the charts and voila, done! Easy, peasy.

One feature that could be useful but wasn’t implemented (due to no immediate need) is the ability to store and upload the data to and from disk in an easily editable format, probably JSON. This could enable us to create backups of Librato Spaces or make our own templates. This should be a quite small fix. So if you’re looking to take your first step in contributing to the world of open source, then this could be something to look in to.

If you would like to checkout CubaLibrato you can do so here.

I would like to thank Librato for having a nicely documented API. And I would also like to thank my team for giving me time to work on something that maybe wasn’t the highest priority but that was useful and that gave me a lot more knowledge and confidence working with Elixir.