SlideShare a Scribd company logo
Managing the logs of your (Rails) applications Lennart Koopmann,  RailsWayCon 2011 www.lennartkoopmann.net / @_lennart
About me 23 years old Living in Hamburg Rails developer at XING AG Developer of Graylog2
What is this log management stuff? Even grepping over flat files can be log management.
Log Management Maturity Scale Log management has different levels – Raffael Marty set up a scale for that.
Level 0 Do not collect logs at all.
Level 1 Collect logs. Mostly simple log files from email or HTTP servers.
Level 2 Use the logs for forensics and troubleshooting. Why was that email not sent out? Why was that HTTP 500 thrown?
Level 3 Save searches. The most basic case would be to save a grep command you used.
Level 4 Share searches. Store that search command somewhere so co-workers can find and use it to solve the same problem.
Level 5 Reporting.
Level 6 Alerting. Automate some of your troubleshooting tasks. Be warned automatically instead of waiting for a user to complain.
Level 7 Collect more logs! We may need more sources for some use cases – Like multi-line application logs, firewall logs or even physical access logs.
Level 8 Correlation. Manual analysis of all this new data may take too long – Correlate different sources.
Level 9 Visual analysis.
Next levels Pattern detection, interactive visualization, dynamic queries, anomaly detection, more sharing.
Collecting logs Two different types.
Type 1 Logs automatically generated from a service. For example apache2.log or mail.log – Usually huge amount of structured, but raw data. jira.graylog2.org:80 x.x.x.x - - [29/May/2011:01:47:38 +0200] "GET /browse/WEBINTERFACE-21?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel HTTP/1.1" 200 7639 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
Type 2 Logs sent directly from within your application. Triggered for example by a log.error() call or an Exception catcher. - Possible to send structured via for example GELF 2011-05-29 18:55:51 +0200 [payment] Could not validate credit card: Got HTTP 404 from example.org
How to send your logs Don't store the logs in flat files. Send them somewhere to get more value out of them.
Syslog Syslog adapters for Rails are available and work pretty good.
GELF Graylog extended log format – Let's you structure your logs. Also check out structured syslog. Ruby library, Rack exception notifier and Ruby logger available. ( www.graylog2.org )
{ ' message ':'[pay] ZOMG credit card invalid', ' full_message ':'Stacktrace.\nSome env vars', ' host ':'www19', ' file ':'/var/www/app.rb', ' line ':2638, ' level ':1, ' _something ':'foo', ' _something_else ':'bar' }
AMQP Guaranteed and ordered delivery. Very flexible. Easily subscribe to the flow. Use routing keys to structure origin of the logs. Hell yeah, use this if you have an AMQP bus available. (or build one) Check out  https://github.com/paukul/amqp_logging
Throw the messages out of your app like a hot potato Loose coupling! Your logs should always leave the application without interfering it! Prefer UDP over TCP, decouple AMQP log transports. Catch all exceptions and get back into the app flow.
Add more value to your logs For example pre-generate geo information for IP addresses or integrate the time_bandits gem.
https://github.com/skaes/time_bandits Completed in 680.378ms (View: 28.488, DB: 5.111(2,0), MC: 5.382(6r,0m), GC: 120.100(1), HP: 0(2000000,546468,18682541,934967)) | 200 OK [ http://127.0.0.1/jobs/info ] Can generate a deep insight view of your application performance when used with LogJam:  https://github.com/alpinegizmo/logjam
Where to send your logs There are a lot of tools available.
Hosted services: Loggly www.loggly.com Dynamic pricing based on your usage Free for 200MB/day with 1 week retention time UDP/TCP/HTTP API as input for syslog
 
 
Hosted services: Splunk www.splunk.com Two license types: Free / Enterprise Supports any raw input
Two more hosted services: www.papertrailapp.com www.logentries.com
Open source tools: Logstash www.logstash.net Collect, parse and store logs for later use Input -> Filter -> Output Plays very well with Graylog2
Logstash inputs For example: AMQP, file, redis, stdin, syslog, tcp, stomp, twitter
Logstash filters For example: date, field, grep, grok, multiline
Logstash outputs For example: amqp, elasticsearch, gelf, mongodb, redis, stdout, tcp, websocket
 
Open source tools: Graylog2 www.graylog2.org Accepts syslog (TCP/UDP) and GELF (+ AMQP) Rails web interface for filtering, analytics, alerting, reporting, … Stores in MongoDB
 
 
 
 
 
Log management use case: API consumer monitoring Something different from the usual alerting, monitoring and reporting.
Pre-processor script (or Logstash) parses raw access log (possibly via AMQP), combines multi line log messages of API engine and extracts value.
oauth_consumer_key, severity, http_status_code, processed (controller#action)
Pre-processor sends the extracted value including the raw message to Graylog2.
n.notify { :severity => 4, :short_message => “UsersController#show [500]”, :full_message => full_msg, :_oauth_consumer_key => “foo”, :_processed => “UsersController#show”, :_http_status_code => 500, ... ... }
Now use Graylog2 and the MongoDB shell to answer questions like...
What consumers are still using the deprecated find user by email call?
What errors are caused by the iPhone application?
Which applications keep causing errors?
Which consumers are inactive?
How many calls are done by the iPhone application and how many were it a month ago?
Extract everything you might need from the message in a structured format you can easily parse and query later. You already have all the data you need!
Q & A @_lennart www.lennartkoopmann.net

More Related Content

ODP
Rails exception tracking with Graylog2 - RubyAndRails 2010 EU
ODP
Graylog2 (MongoBerlin/MongoHamburg 2010)
PDF
Log management with Graylog2 - FrOSCon 2012
PDF
8 Ways Network Engineers use Snabb (RIPE 77)
PDF
OSMC 2008 | An Active Check on the Status of the Nagios Plugins PART 2 by Ton...
PDF
Kafka monitoring and metrics
PPTX
Stephan Ewen - Scaling to large State
PDF
Explore your prometheus data in grafana - Promcon 2018
Rails exception tracking with Graylog2 - RubyAndRails 2010 EU
Graylog2 (MongoBerlin/MongoHamburg 2010)
Log management with Graylog2 - FrOSCon 2012
8 Ways Network Engineers use Snabb (RIPE 77)
OSMC 2008 | An Active Check on the Status of the Nagios Plugins PART 2 by Ton...
Kafka monitoring and metrics
Stephan Ewen - Scaling to large State
Explore your prometheus data in grafana - Promcon 2018

What's hot (20)

PDF
Apache Kafka DC Meetup: Replicating DB Binary Logs to Kafka
PPTX
0.5mln packets per second with Erlang
PDF
PyParis2017 / Tutorial transcript - Function-as-a-service : a pythonic perspe...
PPT
whats new in java 8
PPT
Spark stream - Kafka
PPTX
Sync with async
PPTX
Apache Flink Training: DataStream API Part 1 Basic
ODP
Tcp repair
PDF
Runtime Bytecode Transformation for Smalltalk
ODP
Django debugging
PPTX
AMC Minor Technical Issues
PPTX
Nmap 9 truth "Nothing to say any more"
PDF
Your data is in Prometheus, now what? (CurrencyFair Engineering Meetup, 2016)
PPT
Naresh
PPT
Reactive programming with examples
TXT
Install
PDF
Performance
PDF
Storing 16 Bytes at Scale
PDF
Our way of systems monitoring in application development
Apache Kafka DC Meetup: Replicating DB Binary Logs to Kafka
0.5mln packets per second with Erlang
PyParis2017 / Tutorial transcript - Function-as-a-service : a pythonic perspe...
whats new in java 8
Spark stream - Kafka
Sync with async
Apache Flink Training: DataStream API Part 1 Basic
Tcp repair
Runtime Bytecode Transformation for Smalltalk
Django debugging
AMC Minor Technical Issues
Nmap 9 truth "Nothing to say any more"
Your data is in Prometheus, now what? (CurrencyFair Engineering Meetup, 2016)
Naresh
Reactive programming with examples
Install
Performance
Storing 16 Bytes at Scale
Our way of systems monitoring in application development
Ad

Viewers also liked (13)

PPT
Debugging rails
PDF
MongoDB Operational Best Practices (mongosf2012)
PDF
Petty Cash Management - How To Manage Logs and Transactions
PPT
"Grand Challenges" of Log Management
PPTX
Elastic - ELK, Logstash & Kibana
PPTX
PDF
Ruby on Rails for beginners
DOC
Final project report format
PDF
Ruby on Rails Presentation
PDF
RSpec 2 Best practices
PPTX
Logs management
PPT
Project Report Format
Debugging rails
MongoDB Operational Best Practices (mongosf2012)
Petty Cash Management - How To Manage Logs and Transactions
"Grand Challenges" of Log Management
Elastic - ELK, Logstash & Kibana
Ruby on Rails for beginners
Final project report format
Ruby on Rails Presentation
RSpec 2 Best practices
Logs management
Project Report Format
Ad

Similar to Managing the logs of your (Rails) applications - RailsWayCon 2011 (20)

ODP
Managing the logs of your (Rails) applications - Arrrrcamp 2011
KEY
Message:Passing - lpw 2012
KEY
Messaging, interoperability and log aggregation - a new framework
PDF
Python vs JLizard.... a python logging experience
PDF
Fluentd unified logging layer
PDF
Pycon SE 2022 LT - Python Logging Best Practises
PDF
Graylog for open stack 3 steps to know why
PPTX
Graylog for open stack 3 steps to know why
PDF
Fluentd meetup #2
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
PDF
Monitoring with Syslog and EventMachine (RailswayConf 2012)
PPTX
Logstash
PDF
J-Day Kraków: Listen to the sounds of your application
KEY
London devops logging
PDF
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
PDF
Metrics-Driven Engineering
KEY
Zero mq logs
PDF
Are logs a software engineer’s best friend? Yes -- follow these best practices
PDF
Ruby On Rails Basics
PDF
Railsguide
Managing the logs of your (Rails) applications - Arrrrcamp 2011
Message:Passing - lpw 2012
Messaging, interoperability and log aggregation - a new framework
Python vs JLizard.... a python logging experience
Fluentd unified logging layer
Pycon SE 2022 LT - Python Logging Best Practises
Graylog for open stack 3 steps to know why
Graylog for open stack 3 steps to know why
Fluentd meetup #2
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Monitoring with Syslog and EventMachine (RailswayConf 2012)
Logstash
J-Day Kraków: Listen to the sounds of your application
London devops logging
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Metrics-Driven Engineering
Zero mq logs
Are logs a software engineer’s best friend? Yes -- follow these best practices
Ruby On Rails Basics
Railsguide

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
KodekX | Application Modernization Development
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Electronic commerce courselecture one. Pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
KodekX | Application Modernization Development
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
“AI and Expert System Decision Support & Business Intelligence Systems”
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Electronic commerce courselecture one. Pdf
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I

Managing the logs of your (Rails) applications - RailsWayCon 2011

  • 1. Managing the logs of your (Rails) applications Lennart Koopmann, RailsWayCon 2011 www.lennartkoopmann.net / @_lennart
  • 2. About me 23 years old Living in Hamburg Rails developer at XING AG Developer of Graylog2
  • 3. What is this log management stuff? Even grepping over flat files can be log management.
  • 4. Log Management Maturity Scale Log management has different levels – Raffael Marty set up a scale for that.
  • 5. Level 0 Do not collect logs at all.
  • 6. Level 1 Collect logs. Mostly simple log files from email or HTTP servers.
  • 7. Level 2 Use the logs for forensics and troubleshooting. Why was that email not sent out? Why was that HTTP 500 thrown?
  • 8. Level 3 Save searches. The most basic case would be to save a grep command you used.
  • 9. Level 4 Share searches. Store that search command somewhere so co-workers can find and use it to solve the same problem.
  • 11. Level 6 Alerting. Automate some of your troubleshooting tasks. Be warned automatically instead of waiting for a user to complain.
  • 12. Level 7 Collect more logs! We may need more sources for some use cases – Like multi-line application logs, firewall logs or even physical access logs.
  • 13. Level 8 Correlation. Manual analysis of all this new data may take too long – Correlate different sources.
  • 14. Level 9 Visual analysis.
  • 15. Next levels Pattern detection, interactive visualization, dynamic queries, anomaly detection, more sharing.
  • 16. Collecting logs Two different types.
  • 17. Type 1 Logs automatically generated from a service. For example apache2.log or mail.log – Usually huge amount of structured, but raw data. jira.graylog2.org:80 x.x.x.x - - [29/May/2011:01:47:38 +0200] "GET /browse/WEBINTERFACE-21?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel HTTP/1.1" 200 7639 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
  • 18. Type 2 Logs sent directly from within your application. Triggered for example by a log.error() call or an Exception catcher. - Possible to send structured via for example GELF 2011-05-29 18:55:51 +0200 [payment] Could not validate credit card: Got HTTP 404 from example.org
  • 19. How to send your logs Don't store the logs in flat files. Send them somewhere to get more value out of them.
  • 20. Syslog Syslog adapters for Rails are available and work pretty good.
  • 21. GELF Graylog extended log format – Let's you structure your logs. Also check out structured syslog. Ruby library, Rack exception notifier and Ruby logger available. ( www.graylog2.org )
  • 22. { ' message ':'[pay] ZOMG credit card invalid', ' full_message ':'Stacktrace.\nSome env vars', ' host ':'www19', ' file ':'/var/www/app.rb', ' line ':2638, ' level ':1, ' _something ':'foo', ' _something_else ':'bar' }
  • 23. AMQP Guaranteed and ordered delivery. Very flexible. Easily subscribe to the flow. Use routing keys to structure origin of the logs. Hell yeah, use this if you have an AMQP bus available. (or build one) Check out https://github.com/paukul/amqp_logging
  • 24. Throw the messages out of your app like a hot potato Loose coupling! Your logs should always leave the application without interfering it! Prefer UDP over TCP, decouple AMQP log transports. Catch all exceptions and get back into the app flow.
  • 25. Add more value to your logs For example pre-generate geo information for IP addresses or integrate the time_bandits gem.
  • 26. https://github.com/skaes/time_bandits Completed in 680.378ms (View: 28.488, DB: 5.111(2,0), MC: 5.382(6r,0m), GC: 120.100(1), HP: 0(2000000,546468,18682541,934967)) | 200 OK [ http://127.0.0.1/jobs/info ] Can generate a deep insight view of your application performance when used with LogJam: https://github.com/alpinegizmo/logjam
  • 27. Where to send your logs There are a lot of tools available.
  • 28. Hosted services: Loggly www.loggly.com Dynamic pricing based on your usage Free for 200MB/day with 1 week retention time UDP/TCP/HTTP API as input for syslog
  • 29.  
  • 30.  
  • 31. Hosted services: Splunk www.splunk.com Two license types: Free / Enterprise Supports any raw input
  • 32. Two more hosted services: www.papertrailapp.com www.logentries.com
  • 33. Open source tools: Logstash www.logstash.net Collect, parse and store logs for later use Input -> Filter -> Output Plays very well with Graylog2
  • 34. Logstash inputs For example: AMQP, file, redis, stdin, syslog, tcp, stomp, twitter
  • 35. Logstash filters For example: date, field, grep, grok, multiline
  • 36. Logstash outputs For example: amqp, elasticsearch, gelf, mongodb, redis, stdout, tcp, websocket
  • 37.  
  • 38. Open source tools: Graylog2 www.graylog2.org Accepts syslog (TCP/UDP) and GELF (+ AMQP) Rails web interface for filtering, analytics, alerting, reporting, … Stores in MongoDB
  • 39.  
  • 40.  
  • 41.  
  • 42.  
  • 43.  
  • 44. Log management use case: API consumer monitoring Something different from the usual alerting, monitoring and reporting.
  • 45. Pre-processor script (or Logstash) parses raw access log (possibly via AMQP), combines multi line log messages of API engine and extracts value.
  • 46. oauth_consumer_key, severity, http_status_code, processed (controller#action)
  • 47. Pre-processor sends the extracted value including the raw message to Graylog2.
  • 48. n.notify { :severity => 4, :short_message => “UsersController#show [500]”, :full_message => full_msg, :_oauth_consumer_key => “foo”, :_processed => “UsersController#show”, :_http_status_code => 500, ... ... }
  • 49. Now use Graylog2 and the MongoDB shell to answer questions like...
  • 50. What consumers are still using the deprecated find user by email call?
  • 51. What errors are caused by the iPhone application?
  • 52. Which applications keep causing errors?
  • 53. Which consumers are inactive?
  • 54. How many calls are done by the iPhone application and how many were it a month ago?
  • 55. Extract everything you might need from the message in a structured format you can easily parse and query later. You already have all the data you need!
  • 56. Q & A @_lennart www.lennartkoopmann.net