Honeycomb is a tool to help software engineers and DevOps teams monitor applications, requests, and queries. It is an easy means to start monitoring web applications. In this article, we will add Honeycomb to follow the requests of a Ruby on Rails application and SQL data.
Adding Honeycomb to a Ruby on Rails project
Honeycomb has a gem to add to a Rails project. This gem will connect your Honeycomb account and your project. To add the gem, just include the line below in your Gemfile:
Now, run the bundle to install the new gem:
Create a new config file called honeycomb.rb inside the config/initializers folder and add this code to your key generated inside your Honeycomb dashboard:
HoneycombRails.configure do |conf| conf.writekey = your_key conf.dataset = 'rails-dataset' conf.db_dataset = 'db-dataset' end
This will set the dataset to Rails (rails-dataset) and SQL (db-dataset). To finish the integration, just start or restart the Rails server.
Getting SQL data in Honeycomb
When accessing the Honeycomb dashboard, you can see the datasets defined and integrate them with the project. To view the filters, just click on the dataset.
When you click on db-dataset, you can filter your requests by sql, name, and duration. The list will also show the timestamp of the request. With this data, we can identify the query that has excessive time to run, sorting the list by duration column.
Don’t forget to change the time to select the requests. Below Results, choose Custom to filter any time you want to see. You have start and end time options.
Getting Rails data in HoneycombM
With Rails requests, we have further options under Break Down: action, duration_ms, method, and status. Click on Run to execute the chosen filter. You can also set the controller to see the complete name and sort by status or duration_ms to see whether a request has a problem.
If you click on View Raw Data, you can select fields to facilitate visualization and set what data you can export as JSON or CSV.
To improve integration with the Ruby on Rails project, you can set any meta information to be sent to Honeycomb. Just add the line below in your controller method, passing a name of meta and the value:
honeycomb_metadata[:meta_name] = value
One last good feature of Honeycomb is the integration with Slack that allows for sharing of selected data with the whole team. You just need to click on Share to integrate the data with your Slack account.
Application monitoring is a must for developers and DevOps teams that want to maintain healthy applications. Honeycomb is a complete tool to monitor serverless, web applications and microservices. Honeycomb has many more features to improve your monitoring; in this article, I’ve only shared the basics to start using Honeycomb.