Links
Comment on page

Heroku

Monitor your Heroku Apps with Hosted Graphite.
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:
heroku addons:add hostedgraphite -a <app-name>
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:
heroku config:get HOSTEDGRAPHITE_APIKEY -a <app-name>
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.
Access your new HG account
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:
Heroku auto dashboard
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 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:
heroku labs:enable log-runtime-metrics -a <app-name>
heroku restart -a <app-name>
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.<optional-app-name>.heroku-postgres.<postgres-instance-name> and also report dyno statistics for load and memory. Additionally, you will receive more specific database metrics such as db_size, tables, active/waiting-connections, tmp-disk-available/used, read/write-iops, and more!
We also have a handy Postgres Auto dashboard that is available in our Dashboard Library. Again, these metrics will only be created if your Heroku Postgres add-on is at the standard or premium tier.
Heroku Postgres Dashboard
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).
heroku config -s | grep HOSTEDGRAPHITE_APIKEY >> .env -a <app-name>
more .env
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
apikey = ENV['HOSTEDGRAPHITE_APIKEY']
Python See also: Sending Metrics with Python
apikey = os.environ['HOSTEDGRAPHITE_APIKEY']
Java See also: Sending Metrics with Java
String apikey = System.getenv("HOSTEDGRAPHITE_APIKEY");
PHP See also: Sending Metrics with PHP
$apikey = getenv('HOSTEDGRAPHITE_APIKEY');
Node.js See also: Sending Metrics with Node.js
var apikey = process.env.HOSTEDGRAPHITE_APIKEY;
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 application to send Graphite metrics using a socket connection. Custom metrics can be tailored to track anything you want in your app like logins, sign ups, or cancellations.
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:
heroku labs:enable log-runtime-metrics -a <app-name>
Then, after enabling runtime metrics, you need to restart your Heroku application:
heroku restart -a <app-name>
Finally, you can just point the Heroku app logs to your existing Hosted Graphite account by running the following command:
heroku drains:add https://webhooks.hostedgraphite.com/heroku/<app-name>/logs/\?apikey=<your-api-key> -a <app-name>
NOTE: Make sure to replace the variables <app-name> and <api-key> with their respective details. 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 can take up to 15 minutes for all of the metrics to appear for the first time.
Last modified 27d ago