6. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Whats in a Log Entry?
Lager
• Timestamp
• Severity
• Log Text
• Module
• Function
• Line Number
• Process ID
Saturday, March 23, 13
7. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Whats in a Log Entry?
Lager Popcorn
• Timestamp • Role
• Severity • Node
• Log Text • Version
• Module Coming Soon
• Function • Caller Information
• Line Number • App Metrics
• Process ID • Env Metrics
Saturday, March 23, 13
10. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
From Log Entry to Alert
Log
Alert
Message
• Error
• Warning
• Critical
• Crash
• #identified_topic
Saturday, March 23, 13
11. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Alerts Groups Critical Log Entries
#login_failed for @fearing, returning #404
#login_failed for @ga, returning #404 Alert
#login_success for @bhatia, returning #200
Saturday, March 23, 13
12. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Address Scheme
Role Version Module Line Number
XMPP v2.0.15 user_auth : 54
Saturday, March 23, 13
13. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Crashes have no line number
http_hander:404
http_hander:404
Bad
request
Bad
request
<<“error”>> <<“api/v2”>>
http_hander:404
Bad
request
to ive
u at ********
A ci y
o or
ss m
A e 0fc4cf26168b2a4b959d914682c10bc3
M
Saturday, March 23, 13
14. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Data Stream
Structured Unstructured
• Role • Identity
• Node • Topic
• Version
• Severity
Saturday, March 23, 13
20. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Demo
Using the Calculator HTTP API
curl -v -X POST --data-urlencode "2 4 /"
http://calculator.logwithpopcorn.com/api/calculator
15+
93/
5 2 - (will cause crash)
22*
See and try Popcorn at
http://demo.logwithpopcorn.com/
Saturday, March 23, 13
23. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Customers
• Identify edge case bugs
• Real-time alerting
• Logs as data streams
Support
Saturday, March 23, 13
26. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
UDP or TCP or ...
Connectionless Out of order Dropped packets
No
Quick
acknowledgements
Saturday, March 23, 13
32. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Server Sent Events
SSE
Browser Server
HTTP Post
alert: {key: “001A”, seen:10}
node: {key: “xmpp@con8”, log_msgs:324}
Saturday, March 23, 13
33. SSE Events in JS
$(function() {
var streamSource = new EventSource("/dashboard/stream/{{stream_id}}");
streamSource.addEventListener(
'update_counters',
function(event) {
var counters = JSON.parse(event.data)
// ...
});
streamSource.addEventListener(
'new_node',
function(event) {
var counters = JSON.parse(event.data)
// ...
});
Saturday, March 23, 13
34. SSE Erlang Design
http_stream_handler.erl
-behavior(cowboy_http_handler).
Wait in
New Request Process
init
receive loop
handle handle
path Re
gis
te
Ev r
en
ts fsm node
One FSM per SSE client
Saturday, March 23, 13
40. Processing Time
Over 1,000,000 Requests on Apple Air with R16B
JSON Protobuffs
12 us
9 us
6 us
3 us
0 us
Encoding Decoding
Saturday, March 23, 13
41. Memory
3x
Me Le
JSON Protobuffs m ss
or
y
400 bytes
300 bytes
200 bytes
100 bytes
0 bytes
Memory
Saturday, March 23, 13
42. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Rendering Architecture
Plain Old
Crossfilter D3
Javascript
Used only for
grouping
Store the grouped
streaming data, Rendering
data from
destroyed every
few seconds
Saturday, March 23, 13
55. #POPCORN ERLANG_FACTORY @SF_BAY - 2013
Issue: The Browser
Executing on the server Executing in the browser
vs
(Erlang) (Javascript)
Saturday, March 23, 13