Master
ThoughtWorks
Menu
Close
  • What we do
    • Go to overview
    • Customer Experience, Product and Design
    • Data Strategy, Engineering and Analytics
    • Digital Transformation and Operations
    • Enterprise Modernization, Platforms and Cloud
  • Who we work with
    • Go to overview
    • Automotive
    • Healthcare
    • Public Sector
    • Cleantech, Energy and Utilities
    • Media and Publishing
    • Retail and E-commerce
    • Financial Services and Insurance
    • Not-for-profit
    • Travel and Transport
  • Insights
    • Go to overview
    • Featured

      • Technology

        An in-depth exploration of enterprise technology and engineering excellence

      • Business

        Keep up to date with the latest business and industry insights for digital leaders

      • Culture

        The place for career-building content and tips, and our view on social justice and inclusivity

    • Digital Publications and Tools

      • Technology Radar

        An opinionated guide to technology frontiers

      • Perspectives

        A publication for digital leaders

      • Digital Fluency Model

        A model for prioritizing the digital capabilities needed to navigate uncertainty

      • Decoder

        The business execs' A-Z guide to technology

    • All Insights

      • Articles

        Expert insights to help your business grow

      • Blogs

        Personal perspectives from ThoughtWorkers around the globe

      • Books

        Explore our extensive library

      • Podcasts

        Captivating conversations on the latest in business and tech

  • Careers
    • Go to overview
    • Application process

      What to expect as you interview with us

    • Grads and career changers

      Start your tech career on the right foot

    • Search jobs

      Find open positions in your region

    • Stay connected

      Sign up for our monthly newsletter

  • About
    • Go to overview
    • Our Purpose
    • Awards and Recognition
    • Diversity and Inclusion
    • Our Leaders
    • Partnerships
    • News
    • Conferences and Events
  • Contact
Global | English
  • United States United States
    English
  • China China
    中文 | English
  • India India
    English
  • Canada Canada
    English
  • Singapore Singapore
    English
  • United Kingdom United Kingdom
    English
  • Australia Australia
    English
  • Germany Germany
    English | Deutsch
  • Brazil Brazil
    English | Português
  • Spain Spain
    English | Español
  • Global Global
    English
Blogs
Select a topic
View all topicsClose
Technology 
Agile Project Management Cloud Continuous Delivery  Data Science & Engineering Defending the Free Internet Evolutionary Architecture Experience Design IoT Languages, Tools & Frameworks Legacy Modernization Machine Learning & Artificial Intelligence Microservices Platforms Security Software Testing Technology Strategy 
Business 
Financial Services Global Health Innovation Retail  Transformation 
Careers 
Career Hacks Diversity & Inclusion Social Change 
Blogs

Topics

Choose a topic
  • Technology
    Technology
  • Technology Overview
  • Agile Project Management
  • Cloud
  • Continuous Delivery
  • Data Science & Engineering
  • Defending the Free Internet
  • Evolutionary Architecture
  • Experience Design
  • IoT
  • Languages, Tools & Frameworks
  • Legacy Modernization
  • Machine Learning & Artificial Intelligence
  • Microservices
  • Platforms
  • Security
  • Software Testing
  • Technology Strategy
  • Business
    Business
  • Business Overview
  • Financial Services
  • Global Health
  • Innovation
  • Retail
  • Transformation
  • Careers
    Careers
  • Careers Overview
  • Career Hacks
  • Diversity & Inclusion
  • Social Change
Continuous Delivery Technology

Papertrail Solution for Rails Applications on ElasticBeanstalk

ThoughtWorks ThoughtWorks

Published: Jul 29, 2015

Papertrail is an awesome log aggregation service we’ve used for long time. There are many ways to send logs to Papertail service, but we found the following solution is the most straightforward and secure for Rails apps like ours.

  • Add remote_syslog_logger to Gemfile

gem 'remote_syslog_logger'
  • Configure logger in config/environments/production.rb

config.logger = ActiveSupport::TaggedLogging.new(RemoteSyslogLogger.new("localhost", 514, :program => ))
  • Create papertrail.config in .ebextensions folder with following content:

---
packages:
  yum:
    rsyslog-gnutls: []
files:
  "/etc/rsyslog.d/01-udp.conf":
     mode: "000640"
     owner: root
     group: root
     content: |
       $ModLoad imudp
       $UDPServerRun 514
  "/etc/rsyslog.d/02-papertrail-tls.conf":
     mode: "000640"
     owner: root
     group: root
     content: |
       $DefaultNetstreamDriverCAFile /etc/papertrail-bundle.pem # trust these CAs
       $ActionSendStreamDriver gtls # use gtls netstream driver
       $ActionSendStreamDriverMode 1 # require TLS
       $ActionSendStreamDriverAuthMode x509/name # authenticate by hostname
       $ActionSendStreamDriverPermittedPeer *.papertrailapp.com
container_commands:
  01_copy_ca_certs:
    command: cp ./.ebextensions/papertrail-bundle.pem /etc/papertrail-bundle.pem
  02_install_rsyslog_config:
    command: /bin/echo "*.* @@${SYSLOG_HOST}" > /etc/rsyslog.d/03-papertrail.conf
  03_restart_rsyslog:
    command: "/sbin/service rsyslog restart"
  • Download the latest Papertrail certificate into .ebextensions folder

curl https://papertrailapp.com/tools/papertrail-bundle.pem> .ebextensions/papertrail-bundle.pem
  • Configure SYSLOG_HOST environment variable for each deployment environment. If you use eb_deployer you can add a new option_settings such as:

- namespace: aws:elasticbeanstalk:application:environment
  option_name: SYSLOG_HOST
  value: logs2.papertrailapp.com:xxxx
  • Package, deploy and verify logs are sent to Papertrail

Basically the solution can be described as:

  • Rails app sending log directly to localhost rsyslog daemon using UDP protocol. UDP is a fire-and-forget protocol, so it helps improve logging performance.
  • Then syslog daemon forward logs to Papertrail syslog host using TCP with TLS encryption. Because production logs may have sensitive information we must deliver them through a reliable and secure channel.

sending logs

Reference:

  • Encrypting remote syslog with TLS
Master
Privacy policy | Modern Slavery statement | Accessibility
Connect with us
×

WeChat

QR code to ThoughtWorks China WeChat subscription account
© 2021 ThoughtWorks, Inc.