Top Banner
Wrangling Logs with Logstash and ElasticSearch Nate Jones & David Castro Medi a T empl e OSCON 2012 Thursday, July 19, 12
38

Wrangling Logs With Logstash and ElasticSearch Presentation

Jun 02, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 1/38

Wrangling Logs withLogstash and ElasticSearch

Nate Jones & David Castro

Media Temple

OSCON 2012

Thursday, July 19, 12

Page 2: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 2/38

Why are we here?

Thursday, July 19, 12

Page 3: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 3/38

Size

EfficiencyQuantity

Thursday, July 19, 12

Page 4: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 4/38

Access

Locality Method Filtering

Thursday, July 19, 12

Page 5: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 5/38

Grokability

Noise Structure Metrics

Thursday, July 19, 12

Page 6: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 6/38

Use Case:Mail Logs

Thursday, July 19, 12

Page 7: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 7/38

Size

30 mail servers

2G logs / day / server

60GB / day total

1.8 TB / month

21 TB / year

1 billion log lines per week

Thursday, July 19, 12

Page 8: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 8/38

Access

Front-line, easy access

No SSH

Shareable

Thursday, July 19, 12

Page 9: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 9/38

Grokability

OperationalDid the email get delivered?

Why was the message marked as SPAM?

Are messages being rejected?

Metrics

What's the inbound/outbound message rate?How often are we seeing particular errors?

Thursday, July 19, 12

Page 10: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 10/38

The Solution

Thursday, July 19, 12

Page 11: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 11/38

Overview

Thursday, July 19, 12

Page 12: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 12/38

Overview

Thursday, July 19, 12

Page 13: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 13/38

Logstash Overview

http://logsta.sh/ 

1. Parse log line

2. Transform/extract

3. Structure and send JSON

Thursday, July 19, 12

Page 14: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 14/38

Logstash Parsing

Log line input

2012-07-10T20:00:02.446220-04:00 mail01 spamd[2478]: spamd: cleanmessage (-3.4/5.0) for nobody:93 in 0.0 seconds, 886 bytes.

JSON output

{  "@timestamp" : "2012-07-16T06:44:00.548000Z",  "@tags" : [],  "@fields" : {},  "@source_path" : "/client/127.0.0.1:40010",  "@source" : "tcp://0.0.0.0:6999/client/127.0.0.1:40010",  "@source_host" : "0.0.0.0",  "@message" : "2012-07-10T20:00:02.446220-04:00 mail01 spamd[2478]:spamd: clean message (-3.4/5.0) for nobody:93 in 0.0 seconds, 886bytes.",  "@type" : "maillog"}

Thursday, July 19, 12

Page 15: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 15/38

grok {  type => "maillog"  pattern => "%{TIMESTAMP_ISO8601:timestamp} %{WORD:host}%{SYSLOGPROG:service}: %{GREEDYDATA:message}"}

mutate {  type => "maillog"  # replace the timestamp, correcting import timestamp  replace => ["@timestamp", "%{timestamp}"]  # replace the message sans-timestamp/host/service  replace => ["@message", "%{message}"]}

Logstash Parsing

Thursday, July 19, 12

Page 16: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 16/38

{  "@timestamp" : "2012-07-10T20:00:02.446220-04:00",  "@tags" : [],  "@fields" : {  "pid" : [  "2478"  ],  "service" : [  "spamd[2478]"  ],  "program" : [  "spamd"  ],  "host" : [  "mail01"  ]  },  "@source_path" : "/client/127.0.0.1:39998",  "@source" : "tcp://0.0.0.0:6999/client/127.0.0.1:39998",  "@source_host" : "0.0.0.0",  "@message" : "spamd: clean message (-3.4/5.0) for nobody:93 in 0.0seconds, 886 bytes.",  "@type" : "maillog"}

Logstash Parsing

Thursday, July 19, 12

Page 17: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 17/38

RabbitMQ Overview

http://www.rabbitmq.com/ 

Message Queue

AMQP

Clustered

Thursday, July 19, 12

Page 18: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 18/38

Elasticsearch Intro

http://www.elasticsearch.org/ 

Index in Lucene shards

Cluster-able

Fault tolerant

Thursday, July 19, 12

Page 19: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 19/38

Elasticsearch Head

Thursday, July 19, 12

Page 20: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 20/38

Elasticsearch Browser

Thursday, July 19, 12

Page 21: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 21/38

Kibana Intro

http://rashidkpc.github.com/Kibana/ 

User friendly front-end to elasticsearch

Search log lines

Graph, score, trend

Streaming dashboard

Thursday, July 19, 12

Page 22: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 22/38

Page 23: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 23/38

Kibana Queries

Thursday, July 19, 12

Page 24: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 24/38

Question

Why did the mail for user X get marked as SPAM?

Query

@message:"domain.com" AND @message:"X-SPAM"

Kibana Queries

Thursday, July 19, 12

Page 25: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 25/38

Kibana Queries

Thursday, July 19, 12

Page 26: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 26/38

Question

How many messages are being rejected due to thesending host being listed in an RBL?

Query@message:"zen.spamhaus.org"

Kibana Queries

Thursday, July 19, 12

Page 27: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 27/38

Kibana Queries

Thursday, July 19, 12

Page 28: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 28/38

Question

How many log messages do we have for a specific mailhost?

Query@source_host:"n31"

Kibana Queries

Thursday, July 19, 12

Page 29: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 29/38

Kibana Queries

Thursday, July 19, 12

Page 30: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 30/38

Report Card

Thursday, July 19, 12

Page 31: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 31/38

Size

EfficiencyQuantity

Thursday, July 19, 12

Page 32: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 32/38

Access

Locality Method Filtering

Thursday, July 19, 12

Page 33: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 33/38

Grokability

Noise Structure Metrics

Thursday, July 19, 12

Page 34: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 34/38

Next Steps

Push more stats into graphite

Further breaking down log messages

More stuff

Thursday, July 19, 12

Page 35: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 35/38

Everything you need

Instructions and software

http://logwrangler.mtcode.com/ 

Puppet code and slides

http:// github.com/mediatemple/logwrangler

Local wifi share: logwrangler (guest/guest)

Thursday, July 19, 12

Page 36: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 36/38

Demo

Netcat port for Logstash

RabbitMQ

Elasticsearch

Kibana

Thursday, July 19, 12

Page 37: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 37/38

Contact Info

Nate Jones@ndj

[email protected]

David Castro@arimus

[email protected]

Thursday, July 19, 12

Page 38: Wrangling Logs With Logstash and ElasticSearch Presentation

8/10/2019 Wrangling Logs With Logstash and ElasticSearch Presentation

http://slidepdf.com/reader/full/wrangling-logs-with-logstash-and-elasticsearch-presentation 38/38

Questions?