Setup Heroku

Current.sh provides integration with Heroku via Log Drains.

To configure a Heroku app:

  • Install the current tool
  • Run current heroku -n <current stream> -a <heroku app>
    • For example: current heroku -n widgets -a widgets-api to have the widgets-api app send logs to the current stream widgets
  • In the background, heroku will gather up the apps logs and send them to current. The gather process allows a batch to accumulate before sending, but there is a fairly small timeout. Most logs are processed within 10 seconds of being generated.

Tags

Firstly, to be sure you understand how Current’s tags work, read Log Formatting.

The logs that come from heroku are typically only identified by the app and dyno type that generated them. Current offers an additional vector to annotate the logs via tags. If you specify --tag when you run current heroku, any logs generated will carry that tag as well.

For example:

current heroku -n widgets -a widgets-api --tag environment:production --tag region:heroku

This adds 2 tags to all log entries: environment => production and region => heroku. This can help you organize and categorize your logs much more than trying to just use the app/dyno combo.

With those tags set, you can query based on them in the UI by searching for @environment=production to just show all logs with a tag of environment => production.

Removing

To remove current from logging an app, run: current heroku -n <current stream> -a <heroku app> --remove

Current can be removed manually by listing the drains with heroku drains then passing the url listed to heroku drains:remove.

Technical bits

Current implements a Logplex endpoint that heroku posts logs in batches to. Logplex is great because it allows the sending side to see that the receiver properly process the logs. It also reduces traffic because each request can contain a batch of logs.