Slide 1

Slide 1 text

Monitoring your application

Slide 2

Slide 2 text

About me • Magnus Nordlander • Symfony consultant at Fervo AB • 10 years of PHP experience • SensioLabs certified Symfony Developer (expert level)

Slide 3

Slide 3 text

Launching your application

Slide 4

Slide 4 text

http://www.flickr.com/photos/thelastminute/4397522045/

Slide 5

Slide 5 text

http://www.flickr.com/photos/andresthor/3810596963/

Slide 6

Slide 6 text

Goals • Errors and exceptions • Server and application status • Performance • Usability

Slide 7

Slide 7 text

Strategy • Log exceptions and errors • Monitor server and application status • Monitor performance • E-mail us if something's out of whack • Collect metrics on usability

Slide 8

Slide 8 text

An even better strategy • Log everything • Monitor and record server and application status • Monitor and record performance • Message and call us if something's out of whack • Collect and present metrics on usability

Slide 9

Slide 9 text

Tools • Graylog2 • New Relic • Statsd + Graphite

Slide 10

Slide 10 text

Logging

Slide 11

Slide 11 text

Logging • Log everything • Use log levels and channels to differentiate • Use PSR-3 • Use a framework with logging support

Slide 12

Slide 12 text

Logging in Symfony • Ships with Monolog, PSR-3 compatible • Logs a lot, at various levels • Add gelf-php, and configure the GelfHandler

Slide 13

Slide 13 text

Logging in Symfony "require": { "mlehner/gelf-php": "~1.0", }

Slide 14

Slide 14 text

Logging in Symfony monolog: handlers: main: type: fingers_crossed action_level: info handler: nested nested: type: gelf publisher: hostname: localhost # required port: 12201 # optional chunk_size: 1420 # optional

Slide 15

Slide 15 text

Logging in Symfony $logger->info("Somebody set up us the bomb!", ['foo' => 'bar']);

Slide 16

Slide 16 text

Demo

Slide 17

Slide 17 text

Rule #0: Log everything

Slide 18

Slide 18 text

What should I log? • Symfony logs • Web server logs • PHP error logs • Varnish logs • SSH login attempts

Slide 19

Slide 19 text

Graylog2 • Keep logs for as long as you can • Utilize the extra fields • Add correlation fields • Set up monitoring

Slide 20

Slide 20 text

Application monitoring

Slide 21

Slide 21 text

New Relic • Free, Standard, Pro • Application Performance Management • Server monitoring

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

EkinoNewRelicBundle • Transaction naming • Exception logging • Command monitoring • Deployment notifications

Slide 24

Slide 24 text

Demo

Slide 25

Slide 25 text

New Relic • Use key transactions • Tune your Apdex-T • Set up alerting • Use the plug-ins

Slide 26

Slide 26 text

Statistics

Slide 27

Slide 27 text

Statistics • Dual purpose • Business • Monitoring • Collect as much as you can

Slide 28

Slide 28 text

LiuggioStatsDClientBundle • Uses liuggio/statsd-php-client • Easy to collect statistics yourself • Built-in collectors

Slide 29

Slide 29 text

LiuggioStatsDClientBundle $data = $this ->get('liuggio_stats_d_client.factory') ->increment('pageviews.checkout'); $this->get('liuggio_stats_d_client.service')->send($data);

Slide 30

Slide 30 text

Demo

Slide 31

Slide 31 text

Statsd / Graphite • Collect as much as you can • Build a dashboard • Get TVs for your developers and ops people • Alerting via Seyren

Slide 32

Slide 32 text

Cross-concerns

Slide 33

Slide 33 text

Alerting • E-mail is easy • SMS is better • PagerDuty is awesome

Slide 34

Slide 34 text

Code structure • Events with logging and statistics listeners • Statistics collectors • Libraries with PSR-3 support

Slide 35

Slide 35 text

Be pragmatic

Slide 36

Slide 36 text

Questions? • Contact me at [email protected] • Follow me on Twitter: @drrotmos and @FervoAB • Rate my talk at joind.in/10128