Monitoring Heroku Apps
Tags: devops, heroku, monitoring
Published: 2020-08-12 15:14:01

Heroku differentiates itself from other cloud providers, by offering a complete, cohesive environment. Where AWS and GCP present a decoupled toolkit, Heroku strives for a seamless, UI driven experience for the user. This philosophy is clearly embodied in their metrics functionality, which is often a single click or basic configuration file away. This is clear in its move from hobbyist toolkit to [bedrock](https://coralogix.com/log-analytics-blog/how-capgemini-solved-multi-cloud-observability-on-heroku-salesforce/) of huge, enterprise solutions.

## Make use of Metrics

Heroku exposes metrics functionality via a clean tab on the UI. This allows users to track the behaviour of their system. If you’re running your software in a web dyno, you are already gathering metrics. These range from error statuses, such as 5XX and 4XX HTTP response codes, to latency times. These are basic raw metrics. For example, latencies can be viewed by percentile, to provide a clear indication of, not just the average of your application's response time, but also the variance. Access to this sort of statistical analysis greatly improves observability and speeds up troubleshooting, especially considering these measurements were gathered for you automatically. While these measurements are not a part of the Heroku free-tier, they are available on a hobbyist subscription, at $7 a month.

## The Logging CLI

The Heroku CLI comes packed with a ton of great features. One of the basic, easy to use features is the Heroku logging toolkit. This is actually a basic type of log collection. When you have a handful of dynos, all running instances of your application, this CLI is able to give you a single view of all of those logs with a single command:

```
heroku logs --app=monitoring-test-application --tail
```

This is often a herculean task for organisations, requiring weeks of complex engineering effort and ongoing maintenance that only grows with the scope and scale of your system. Out of the box log collection is very consistent with the simple, intuitive mentality that Heroku applies.

## Auditing

When we think of monitoring, we’re immediately taken to graphs, displaying HTTP latencies and error rates. We often overlook other sorts of monitoring and observability, such as the changes that are being applied to our system. In a bespoke set up, auditing is usually driven by an organisational requirement for security compliance and is inserted as an afterthought. Heroku have baked this into their UI, so that from the start, you can see the changes that are being applied to your deployment, as they happen.

## Add-Ons 

Add-Ons are Heroku’s method of adding modular functionality into your deployment. There is a vast array of add-ons available that extend the capability of your stack, and many of these support more sophisticated monitoring. As is often the case with this provider, they can rely on the opinionated underpinnings of the Heroku system, making for a seamless and straight forward experience. 

They come with their own billing mechanism, meaning that you can choose to pay for a deluxe version of one add-on while only committing to a standard version of another. While this flexibility creates the opportunity for cost optimisation, these various small subscriptions can quickly add up. Add-ons are an essential part of the Heroku landscape, but keep track of the many different tools you will need. This modular billing system can become difficult to track, over time.

## The best tool for the Job

To address the limitations of the add-on system within Heroku, you may scale to a point where it is necessary to export certain data into other platforms. While the monitoring solutions of Heroku are outstanding, they, much like the rest of the Heroku tooling, are opinionated. This means that for most use-cases, they will work, but as complexity grows and the need for more bespoke solutions arises, you may be forced to branch out.

This can, ironically, be solved by more add-ons. For example, if you outgrow the simple logging CLI that Heroku offers, you can install the Coralogix add-on for your application. Should you need to enhance your container scanning capability. If you need to do something incredibly bespoke, you can build your own add-on to export metrics, logs, and other data into your own systems.

This property, known as extensibility, means that when there is not an “off the shelf” solution available to you, you’re able to extend your deployment in new and unexpected directions. This is a key capability for any rapidly scaling architecture, that can’t afford to find itself handcuffed to a limited set of functionality by a service provider.

## All in all

Heroku is a fantastic environment. The tools that are seamlessly presented to you will capture many of the typical use-cases found, during the lifetime of a software project. For larger or more complex projects, Heroku’s openness and extensibility creates constant avenues for innovation, while maintaining the opinionated consistency that underpins Heroku’s engineering experience. While caution must be exercised around the billing and cost optimisation of the various add-ons and servers, with some forethought, planning and the right 3rd party integrations, Heroku is capable of competing with even the mammoths of the cloud platform world.

---
Chris writes about DevOps and Monitoring for [Coralogix](https://coralogix.com/).