06 How do I debug my app?
This content is copyright of CloudCredo. © CloudCredo 2015. All rights reserved.
Feature
As a CF hero
I want to know what my CF app is doing
So that I can debug it
Push a buggy app
# From the training home directory:
$ cd 06-debugging/debug-app
$ cf push
...
urls: debug-app-unerring-muddlehead.cfapps.io
...
How do I debug my app?
- App logs
- App events
- App instrumentation
- SSH access
1. App logs
$ cf logs debug-app --recent
...
... [App/0] ERR ... - RuntimeError - I am a bug, fix me:
... [App/0] ERR /home/vcap/app/config.ru:20:in `block in <class:Web>
$ cf logs debug-app # Tails app logs, CTRL + C to exit
Let's fix the app
$ cf set-env debug-app FIXED true
$ cf restart debug-app
2. App events
$ cf events debug-app
... description
... index: 0, reason: CRASHED, exit_description: 2 error(s) ...
...
Note: Notice that the most recent event is at the top
3. App instrumentation
- New Relic
- AppDynamics
Included in Java buildpack
New Relic instrumentation
$ cf create-service newrelic standard newrelic
$ cf bind-service debug-app newrelic
$ cf env debug-app
# Find your New Relic license key
# From the training home directory:
$ cd 06-debugging/debug-app
# Replace YOUR-LICENSE-KEY
$ vim newrelic.yml
$ cf push
$ cf service newrelic
Note: Create a New Relic service instance
Provide app with New Relic license key
Find New Relic Dashboard URL
Generate some load
4. SSH access
$ cf ssh debug-app
DELIVERED
As a CF hero
I want to know what my CF app is doing
So that I can debug it
Any questions?
Questions cannot be stupid. Answers can.
CF SUPERHERO
- Setup Skylight for app
- Setup Opbeat for app
- Learn about CF Logging and Metrics
- Send app logs to Papertrail
$ cf cups logdrain -l syslog://YOUR-PAPERTRAIL-LOG-DESTINATION
$ cf bind-service debug-app logdrain
# Check your Papertrail Events, no need to restart the app
No comments:
Post a Comment