dtm a logstash pattern

18
1 Logstash Pattern - DTM

Upload: christian-mague

Post on 26-May-2015

453 views

Category:

Technology


0 download

DESCRIPTION

Use the DTM pattern to allow developers to quickly add stats and easily searchable events to your application.

TRANSCRIPT

Page 1: DTM a Logstash pattern

1

Logstash Pattern - DTM

Page 2: DTM a Logstash pattern

2

Goal

1) Ensure that developers can quickly get comprehensive log and performance data without operations intervention.

2) Avoid a complete rewrite of code.

3) Avoid brittle regexp parsing that may change often.

Page 3: DTM a Logstash pattern

3

Solution – DTM

● - DTM stands for nothing● - Just a short string that rarely appears in the languages that I support● - Good intermediate step

Page 4: DTM a Logstash pattern

4

Fixes...

Log in JSON

- parsing is cheap

- format change is fine

Page 5: DTM a Logstash pattern

5

Example Usage

Calls to some 3rd party API are failing intermittently and/or taking too long

How do I figure out what is going on when there are several hundred requests a second and there are 40 app servers?

I don't have the time to re-write all of the logging code to use JSON

Page 6: DTM a Logstash pattern

6

Answer...

Use DTM_EVENTS and DTM_STATS

Page 7: DTM a Logstash pattern

7

Sample Code

Page 8: DTM a Logstash pattern

8

Outputs the following log lines

2013-11-14T23:36:23.491037+00:00 app[web.1]: {"DTM_EVENT":"Failure","fail":"BROKEN","user":"chris","group":"admins"}

2013-11-14T23:36:43.080817+00:00 app[web.1]: {"DTM_STATS":"outside_api.fetch","value":0.089154052734,"stat_type":"timer"}

Page 9: DTM a Logstash pattern

9

DTM_EVENTS

-JSON Blob

-Needs a unique DTM_EVENT field

{"DTM_EVENT":"Failure",

"fail":"BROKEN",

"user":"chris",

"group":"admins"}

Page 10: DTM a Logstash pattern

10

Example Config (pre 1.3)

Page 11: DTM a Logstash pattern

11

Page 12: DTM a Logstash pattern

12

DTM_STATS

- JSON blobs

{"DTM_STATS":"outside_api.fetch",

"value":0.0001437664031982422,

"stat_type":"timer"}

Required fields

1) DTM_STATS – stat name

2) value number

3) stat_type

timer, counter, gauge

Page 13: DTM a Logstash pattern

13

DTM_STATS types

Timer -

Timed events

Statsd provides the following data count_ps count lower mean_90 mean median std sum_90 sum upper_90 upper

Counter -

Rate events eg: number of HTTP 200's a second

Gauge -

Number during a given time period eg: 7 200's in the past minute

Page 14: DTM a Logstash pattern

14

Example Config (pre 1.3)

Page 15: DTM a Logstash pattern

15

Can be found in graphite

stats.timers.dtm_stats.application.heroku.staging.outside_api.fetch.mean_90

stats.guage.dtm_stats.application.heroku.staging.STAT

stats.counter.dtm_stats.application.heroku.staging.STAT

Page 16: DTM a Logstash pattern

16

Examples of Graphite GraphsCan be saved under UserGraphs

Page 17: DTM a Logstash pattern

17

More Information

Graphite on EC2

http://shokunin.co/blog/2013/03/16/graphite_on_ec2.html

Elasticsearch for Logstash

http://shokunin.co/blog/2013/06/24/elasticsearch.html

Map visualizations

http://shokunin.co/blog/2013/05/10/maptail_plus_logstash.html

Page 18: DTM a Logstash pattern

18

Thanks!

Chris Mague

Shokunin.co

[email protected]

IRC - #bosszaru

AIM - maguech