Heroku
Monitor your Heroku Apps with Hosted Graphite.
Last updated
Monitor your Heroku Apps with Hosted Graphite.
Last updated
Contents:
Hosted Graphite has a Heroku Add-On! Installing the add-on can be done through the UI of your Heroku account in the ‘Resources’ section, or by issuing the following command in your Heroku CLI:
Make sure to replace the variable <app-name> with the name of your application, as it appears in your Heroku account. Once the add-on is installed, a new application configuration key will be created, called HOSTEDGRAPHITE_APIKEY
. Confirm the key by issuing this command:
You can now navigate to your new account by clicking on the Hosted Graphite add-on link in the Heroku UI, and wait for the metrics to appear.
For more documentation around our Heroku Add-On, please visit the Hosted Graphite on Heroku page.
This dashboard will be automatically created when you enable the Heroku Add-On, or configure Log-Drain metrics to your existing Hosted Graphite account.
Using Heroku’s Log-Runtime metrics we retrieve and process Heroku’s syslog information for your Dynos including:
Load average - 1/5/15-minute averages
Memory and Swap - Resident memory, disk cache, swap, total memory, and cumulative totals for pages written to/read from disk.
HTTP metrics - The number of requests broken down by HTTP method and status codes, data transferred, and connect/service times.
Troubleshooting: If you are not receiving the web dyno metrics (web/cpu/mem), you likely need to enable log-runtime metrics for your Heroku app. Log into your Heroku CLI and run the following commands:
If you use the Heroku Postgres add-on at the standard or premium tier, these metrics will automatically forward to your Hosted Graphite account. They are prefixed with: heroku.<app-name>.heroku-postgres.<instance-name>.<type> and report dyno statistics for cpu load, memory, db_size, tables, active/waiting-connections, tmp-disk-available/used, read/write operations, and more!
We also have a handy Heroku Postgres dashboard that is available in our Dashboard Library.
If you use the Heroku Redis add-on at any tier, these metrics will be automatically forwarded to your Hosted Graphite account. They are prefixed with: heroku.<app-name>.heroku-redis.<instance-name>.<type> and report dyno statistics for load, memory, reads/writes, connections, and more!
We also have a Heroku Redis dashboard that is available in our Dashboard Library.
If you use the Heroku Kafka add-on at the Standard tier or above, these metrics will automatically forward to your Hosted Graphite account. They are prefixed with: heroku.<app-name>.heroku-kafka.<node>.<instance-name>.<type> and report per-node statistics for load, memory, reads/writes, operations, and more!
We also have a Heroku Kafka dashboard that is available in our Dashboard Library.
In your local development environment, it will be necessary to replicate the above configuration. Since the Foreman tool will look in the .env
file for development environment variables, use the following command to copy the HOSTEDGRAPHITE_APIKEY
from the Heroku config (Do not check the file .env
into source control).
More information on accessing your API key is detailed in the below section.
Now that the add-on has been set up, the Hosted Graphite API Key will be available via the environment variable HOSTEDGRAPHITE_APIKEY. See the appropriate language snippet below for an example of how to access this variable in your app.
Ruby See also: Sending Metrics with Ruby
Python See also: Sending Metrics with Python
Java See also: Sending Metrics with Java
PHP See also: Sending Metrics with PHP
Node.js See also: Sending Metrics with Node.js
You can also send custom application metrics to your Hosted Graphite account. We provide code snippets in our language guide that can be configured throughout the codebase of your Heroku app to send Graphite metrics through a socket connection. Custom metrics can be tailored to track anything you want in your app like logins, sign ups, or cancellations.
Check out our video tutorial on configuring a custom StatsD metric to report an event from your Heroku app => to your Hosted Graphite account.
If you enable the Path Metrics feature in the Heroku Config, we will collect and forward router statistics (connection times, request methods/statuses) per path in your Heroku application. This will increase the total number of metrics being stored in the Hosted Graphite backend, but will give you increased visibility into activity within your app, and a higher level of alerting functionality.
We offer these metrics in a dot.notation.format, or an underscore_format giving you the option to choose the metric cardinality that works best for you:
heroku.<appname>.<host>.router.<path(url.com.sub-path)>.<rest_of_metric>
or
heroku.<appname>.<host>.router.<path(url_com_sub-path)>.<rest_of_metric>
If left on the 'default' metric format, you will receive the standard router metrics giving you a good overview of the activity within your Heroku app. The default router metrics are what can be seen on your Heroku Auto Dashboard.
If you have Path Metrics enabled, but experience a high cardinality of metrics due to unique identifiers being created in your app's URLs, our Router Aggregates feature will combine these values to reduce your metric overhead. For example, lets say your app generates endpoints with ID placeholders for a customer each time a route is accessed: "GET /api/path/<placeholder-id>"
This could create a lot of unique heroku router metrics in your account and you might be better of receiving only 1 metric with a combined value. Simply define a path with the variable in curly brackets {placeholder-id} to combine multiple metrics into one! NOTE: Path metrics must first be enabled in your HG account, and you can define as many Router Aggregate paths as you like.
We also provide a convenient webhook that you can upload to your Heroku account and import real-time Heroku events to your Hosted Graphite account:
Once you have added the webhook into your Heroku account, you can configure annotations on your dashboards to display events from your Heroku environment around deployments, builds, domains, collaborators, add-ons, and more!
Its easy to forward your log drain metrics to an existing Hosted Graphite account. This is actually a better value because a dedicated HG account allows you to configure multiple heroku apps, get the full 2 year data retention, and premium level support for the same price as the Heroku add-on.
First, you will need to make sure the Heroku ‘appname format’ is enabled if you wish to include your appname in the metric naming scheme (recommended). Navigate to Add-Ons => Heroku, and confirm that the checkbox is checked.
Next, you will need to enable Log-Runtime metrics by running the following command in your Heroku CLI:
Then, after enabling runtime metrics, you need to restart your Heroku application:
Finally, you can just point the Heroku app logs to your existing Hosted Graphite account by running the following command:
NOTE: To avoid any duplicate metrics, make sure to enable both the 'appname format' checkbox in the Add-Ons UI, and include the appname in the above drains:add
command. You are able to ship metrics from as many Heroku apps as you like, but it takes about 15 minutes for all of the metrics to appear for the first time.