Monitoring Dokku Container Logs with SolarWinds Papertrail - Papertrail Blog

The revolution will be verbosely {,b}logged

Monitoring Dokku Container Logs with SolarWinds Papertrail

Posted by Papertrail Team on

If you are looking for a Docker-enabled PaaS, but want to run it on your own infrastructure, Dokku might be a great option to consider. It is basically lightweight open source software that runs on your server. Dokku simplifies deployment by handling the movement of source code, containerization of sites, assignments of domains, builds, SSL certs, and more—just like a cloud-based PaaS. 

Dokku apps are restricted to a single host. When you don’t have enormous scaling needs, Dokku might be a great option. Prototyping, for example, is perfect for Dokku.  You can quickly pull a prototype together and get it out to users for feedback, frequently in the same day. It lets DevOps teams spend more time designing and building projects and less time fiddling with server configurations and deployment issues.

SolarWinds® Papertrail is a perfect option for managing Dokku logs. Like Dokku it is lightweight and quick to setup and get started with. Papertrail allows you to access all your Dokku apps from a single location, stream events in real time, or filter events by component, resource, or date range. You can also set up alerts to automatically notify you in case of unexpected problems or unusual behavior.

 Here’s how to push Dokku app logs into Papertrail.

Install dokku-logspout: dokku plugin:install https://github.com/michaelshobbs/dokku-logspout.git

  1. Point logspout to your Papertrail syslog endpoint:dokku logspout:server syslog+tls://logs.Papertrailapp.com:12345. Make sure your Papertrail endpoint is configured to accept TLS connections.

  2. Install dokku-hostnamedokku plugin:install https://github.com/michaelshobbs/dokku-hostname.git dokku-hostname. This will ensure that the host in your Papertrail logs use the heroku-like name of your worker instead of the docker container ID.

  3. Rundokku logspout:startand uselogspout:streamto ensure that your logs are being aggregated  properly.

The resulting log output should look something like:

Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/processor.rb:167:in `stats'
Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/processor.rb:79:in `process_one'
Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/processor.rb:67:in `run'
Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/util.rb:16:in `watchdog'
Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/util.rb:24:in `block in safe_thread'
Apr 15 14:49:28 host.com pipeline.worker.1:  11 TID-os97lykxo INFO: [Rollbar] Scheduling payload

A few things to keep in mind:

  • You may need to rebuild your apps for them to start piping to logspout.dokku ps:rebuildall.
  • When you re-deploy your apps, the heroku-like program names will be lost. To fix this rundokku logspout:stop && dokku logspout:start.
  • If docker psreturns a daemon error. Runsudo usermod -aG docker ubuntu && sudo rebootasubuntu.

Now that you have the logs in Papertrail, you will see events streaming in real time on the Papertrail events pages. Each event is appended with the resource name appearing in the System field, and the component that logged it appearing in the Program field. To simplify searching, Papertrail makes the request_id selectable.  You can simply click on it or copy and search it in the Event Viewer to find all the app logs that are causing the problems, along with any related error message from your application’s code. 

Monitoring and alerting are other reasons to add a logging solution[  to Dokku applications. In Papertrail, you can save a search while you are troubleshooting to create an alert. Once you select save, you will see the ‘save’ and ‘setup alert’ options:

Fig 2. Save a log search and set up an alert with a single action

You can also set up the alert delivery options, such as email, Slack message, push notifications, or custom webhooks, in the next screen. Once you set up the alert, Papertrail will monitor and notify you if any error messages matching that search occur in your logs.

Even when prototyping, log management is important. Implementing a simple solution like Papertrail can help you identify and resolve issues faster so you can maximize the feedback you get from your users.

To sum it up, if you are in an agile shop and looking for solutions to help you get projects out of dev and into the hands of users to provide feedback, the combination of Dokku and SolarWinds® Papertrail™ may be for you.

Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/processor.rb:167:in stats' Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/processor.rb:79:inprocess_one'
Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/processor.rb:67:in run' Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/util.rb:16:inwatchdog'
Apr 15 14:49:28 host.com pipeline.worker.1:  /app/vendor/bundle/ruby/2.3.0/gems/sidekiq-4.1.1/lib/sidekiq/util.rb:24:in `block in safe_thread'
Apr 15 14:49:28 host.com pipeline.worker.1:  11 TID-os97lykxo INFO: [Rollbar] Scheduling payload