Listen to the sounds of your application
Krzysztof Ciesielski
softwaremill.com
@kpciesielski

Lublin Software Craftsmen

!2
Maciej Biłas
softwaremill.com
@maciejb

jbison.com

!3
Agenda
• Monitoring, huh?
• Introducing Graphite
• Log analysis – the whys
• Logstash architecture & use cases
• Exploring logs with Kibana

!4
Monitoring, huh?

!5
source: codeascraft.com
!6
Types of measurements

!7
Types of measurements

Network

!7
Types of measurements

Network
Machine

!7
Types of measurements

Network
Machine
Application

!7
source: codeascraft.com
!8
measurement > prediction

!9
!10
measurement >> prediction

!11
Our stack

!12
Our stack
Server
App

Server

…

App

!12
Our stack
Server
App

Graphite

Server

…

App

Logstash

!12
Our stack
Server
App

Graphite

Server

…

App

Logstash

!12
Our stack
Server
App

Graphite

Server

…

App

Logstash

!12
Our stack
Server
App

Graphite

Server

…

App

Logstash

!12
Our stack
Server
App

Graphite

Server

…

App

Logstash

!12
Our stack
Server
App

Server

…

App

Yammer Metrics

Graphite

Logstash

!12
Introducing Graphite

!13
Graphite

!14
PORT=2003
SERVER=graphite.your.org
echo "local.random.diceroll 4 `date +%s`" | nc ${SERVER} ${PORT}; 

!15
successful.login.attempt 1 1384471287
successful.login.attempt 1 1384471297

!16
successful.login.attempt 1 1384471287
successful.login.attempt 1 1384471297

=> successful.login.attempt = 1

!16
Yammer Metrics

!17
Yammer Metrics

private final Meter successfulLogins =
metrics.meter(name(LoginHandler.class, "successful"));

!

public void login(String user, String password) {
if (canLogin(user,password)) {
successfulLogins.mark();
// ...
} else {
// ...
}
}

!17
Metrics

!18
Metrics
Types:

!18
Metrics
Types:
• Gauges

!18
Metrics
Types:
• Gauges
• Counters

!18
Metrics
Types:
• Gauges
• Counters
• Meters

!18
Metrics
Types:
• Gauges
• Counters
• Meters
• Histograms

!18
Metrics
Types:
• Gauges
• Counters
• Meters
• Histograms
• Timers

!18
Metrics
Types:
• Gauges
• Counters
• Meters
• Histograms
• Timers
• Health Checks

!18
Metrics
Types:

Reporters:

• Gauges

• STDOUT

• Counters

• CSV

• Meters

• SLF4J

• Histograms

• JMX

• Timers

• Graphite

• Health Checks

• Ganglia

!18
Counters, meters…
vs.
Gauges

!19
Aggregation

!20
source: codeascraft.com
!21
You can also check out
• collectd https://collectd.org
• StatsD https://github.com/etsy/statsd/
• Riemman http://riemann.io/
• Twitter’s Ostrich https://github.com/twitter/ostrich
• Ganglia http://ganglia.sourceforge.net/
• Dashboards:

http://shopify.github.io/dashing/

https://github.com/obfuscurity/descartes

https://github.com/obfuscurity/dusk

!22
Event Sourcing
Tracing and storing all the events
Current app state: replaying the stream
Great for data mining and analysis

!23
Log aggregation

Less invasive way to build an “event stream”
Logs are data with plenty of value

!24
Log aggregation
Log
source

Log
source

Central
storage

Query
engine

Web
view

Log
source

!25
Logstash
Open Source (written in JRuby)

!26
Logstash
Open Source (written in JRuby)
Gathers logs from various inputs

!26
Logstash
Open Source (written in JRuby)
Gathers logs from various inputs
Parses and extracts metadata

!26
Logstash
Open Source (written in JRuby)
Gathers logs from various inputs
Parses and extracts metadata
Writes to various outputs

!26
Logstash
Open Source (written in JRuby)
Gathers logs from various inputs
Parses and extracts metadata
Writes to various outputs
Similar tools:

!

Splunk, Graylog, Fluentd, log.io

!26
Logstash
centralized architecture

!27
Logstash
grok
2013-11-10 19:41:25.321 [main]
INFO o.a.camel.impl.DefaultCamelContext

!

- Apache Camel 2.11.1 (CamelContext: camel-1) started in 4.450 seconds

!28
Logstash
grok
2013-11-10 19:41:25.321 [main]
INFO o.a.camel.impl.DefaultCamelContext

!

- Apache Camel 2.11.1 (CamelContext: camel-1) started in 4.450 seconds
time

2013-11-10 19:41:25.321

thread

main

loglevel

INFO

source

o.a.camel.impl.DefaultCamelContext

message

Apache Camel 2.11.1 (CamelContext: camel-1) started in 4.450 seconds

!28
Logstash
simple use cases
Grok:
Exceptions
Security issues
Rare and business-meaningful events

Output: e-mail alert

!29
Kibana

!30
Kibana
checking general app activity

!31
Kibana
Spotting anomalies

!32
Kibana
Checking regular events

!33
Kibana
How often is this feature used?

!34
Kibana
Displaying multiple query results
Query: exception
Type: applog

Query: index
Type: mongolog

!35
References
• Graphite http://graphite.readthedocs.org/en/latest/
• Yammer Metrics http://metrics.codahale.com/
• Logstash http://logstash.net/
• Surfing the event stream by Sam Newman at Geecon

http://www.slideshare.net/spnewman/surfing-the-event-stream
• Lessons from Building and Scaling LinkedIn by Jay Kreps

http://www.infoq.com/presentations/linkedin-architecture-stack
• Code as Craft http://codeascraft.com/

!36
!37
Thank You

Reach us at:
@maciejb and @kpciesielski
softwaremill.com

!38

J-Day Kraków: Listen to the sounds of your application