Estimated Time: 25 minutes

1. Preface

Cloud Foundry’s loggregator subsystem routes applications' log streams out of the containers from which they emanate, and makes them accessible via the cf logs command.

But what if you needed to maintain a month’s worth of logs, and wanted to leverage third party tools or services for log analysis? Cloudfoundry provides the capability to drain application logs to some destination, whether it be an internal enterprise system or a third-party service.

In this lab, you’ll setup a log drain for your application using a service called Papertail.

2. Exercises

2.1. Create a log drain

Pivotal Cloud Foundry does not persist logs. For long term storage of logs, drain logs to a third party log management service.

  1. Read about log draining.

    In this section, you will configure application log draining into a log analysis tool with a User Provided Service Instance. We will use the free Papertrail service, but any tool that supports tcp syslog draining can be used.

  2. Sign up for a free Papertrail account. We’ve got some instructions to set up Papertrail.

    In a nutshell:

    1. Create a Papertrail account, fill in your email and password

    2. Browse to papertrailapp.com/systems/new

    3. Select "I use Cloud Foundry"

    4. "What should we call it?" give it a name - log-drain

    5. Click "Save"

    6. Take note of the url (logs2.papertrail.com:<some-port>)

  3. Create a User Provided Service Instance that streams logs to Papertrail.

    cf create-user-provided-service articulate-log-drain -l syslog://{{syslog_drain_url}}
  4. Bind the articulate-log-drain service to the articulate application.

    cf bind-service articulate articulate-log-drain
    It can take up to ten minutes for logs to start flowing into Papertrail. At the time of writing, this was consistently 10 minutes before seeing logs in Papertrail.

    Question: Is cf restart/restage required for log draining to start working? Why? Why not?

  5. View articulate in a browser. Refresh as necessary to generate logs.

  6. To view the logs in Papertrail do the following:

    1. Click on "Dashboard"

    2. Click on "log-drain"

  7. Experiment. Restart the articulate application.

    cf restart articulate

3. Questions

  • How does this approach differ from how you get your logs today?

  • What kinds of alerts or visualizations could you create from your logs data?

4. Beyond the Class

  • Visualize your logs