73
From Zero to Hero Rafał Kuć – Sematext Group, Inc. @kucrafal @sematext sematext.com Easy log centralization with Logstash & Elasticsearch

From zero to hero - Easy log centralization with Logstash and Elasticsearch

Embed Size (px)

DESCRIPTION

Presentation I gave during DevOps Days Warsaw 2014 about combining Elasticsearch, Logstash and Kibana together or use our Logsene solution instead of Elasticsearch.

Citation preview

Page 1: From zero to hero - Easy log centralization with Logstash and Elasticsearch

From Zero to Hero

Rafał Kuć – Sematext Group, Inc.

@kucrafal @sematext sematext.com

Easy log centralization with Logstash & Elasticsearch

Page 2: From zero to hero - Easy log centralization with Logstash and Elasticsearch

About me…

Sematext consultant & engineer

Solr.pl co-founder

Father and husband

Page 3: From zero to hero - Easy log centralization with Logstash and Elasticsearch

The problem

Page 4: From zero to hero - Easy log centralization with Logstash and Elasticsearch

The problem

Log Log

Log

Log Log

Log Log

Log Log

Page 5: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Let’s find something

http://www.likesbooks.com/aarafterhours/?p=750

Page 6: From zero to hero - Easy log centralization with Logstash and Elasticsearch

The solution

Log Log Log Log

Log Log

Log Log

Page 7: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Available tools

Page 8: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Available tools

Page 9: From zero to hero - Easy log centralization with Logstash and Elasticsearch

But why search?

Easy to find related data

Page 10: From zero to hero - Easy log centralization with Logstash and Elasticsearch

But why search?

Easy to find related data

Fast and accurate

Page 11: From zero to hero - Easy log centralization with Logstash and Elasticsearch

But why search?

Easy to find related data

Fast and accurate

Real time data insight and analysis

Page 12: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Why Elasticsearch?

Reasonable defaults

Distributed by design

http://www.dailypets.co.uk/2007/06/17/kittens-rest-at-half-time/

Page 13: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Installation

$ wget --no-check-certificate https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.tar.gz

Page 14: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Installation

$ wget --no-check-certificate https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.tar.gz

$ tar –xvf elasticsearch-1.3.2.tar.gz $ elasticsearch-1.3.2/bin/elasticsearch

Page 15: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Installation

$ wget --no-check-certificate https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.tar.gz

$ tar –xvf elasticsearch-1.3.2.tar.gz $ elasticsearch-1.3.2/bin/elasticsearch

Page 16: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Scalable

Page 17: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Scalable

Page 18: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Scalable

Page 19: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - stability

Page 20: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - stability

Page 21: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - stability

Page 22: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - stability

minimum_master_nodes =

N/2 + 1

Page 23: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - stability

Master only

Master only

Master only

Data only

Data only

Data only

Data only

Data only

Data only

Client only

Client only

minimum_master_nodes =

N/2 + 1

Page 24: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Thread pools

Page 25: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Thread pools Use fixed

Set size

Set queue

Page 26: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Thread pools

threadpool.search.type threadpool.search.size

threadpool.search.queue_size

threadpool.index.type threadpool.index.size

threadpool.index.queue_size

threadpool.bulk.type threadpool.bulk.size

threadpool.bulk.queue_size

Use fixed

Set size

Set queue

Page 27: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Circuit breakers, caches == no OOM

indices.breaker.fielddata.limit indices.breaker.fielddata.overhead

40% Xmx 1

Page 28: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Circuit breakers, caches == no OOM

indices.breaker.fielddata.limit indices.breaker.fielddata.overhead

indices.breaker.request.limit indices.breaker.request.overhead

60% Xmx 1.03

40% Xmx 1

Page 29: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Circuit breakers, caches == no OOM

indices.breaker.fielddata.limit indices.breaker.fielddata.overhead

indices.breaker.request.limit indices.breaker.request.overhead

indices.breaker.total.limit 70% Xmx

60% Xmx 1.03

40% Xmx 1

Page 30: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Circuit breakers, caches == no OOM

indices.breaker.fielddata.limit indices.breaker.fielddata.overhead

indices.breaker.request.limit indices.breaker.request.overhead

indices.breaker.total.limit

indices.fielddata.cache.size unbounded

70% Xmx

60% Xmx 1.03

40% Xmx 1

Page 31: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Circuit breakers, caches == no OOM

indices.breaker.fielddata.limit indices.breaker.fielddata.overhead

indices.breaker.request.limit indices.breaker.request.overhead

indices.breaker.total.limit

indices.fielddata.cache.size

indices.cache.filter.size

unbounded

10%

70% Xmx

60% Xmx 1.03

40% Xmx 1

Page 32: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - indexing

Log

Page 33: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - indexing

Log

Page 34: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - indexing

Log

Log Log

Log Log

Log Log Log Log Use

Bulk! Or UDP

Bulk!

Page 35: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Configuration - indexing

Log

Log Log

Log Log

Log Log Log Log

index.translog.flush_threshold_ops index.translog.flush_threshold_size

unlimited 200mb

Use Bulk!

Or UDP Bulk!

Page 39: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Data volume under control

2014-09-24

Page 40: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Data volume under control

2014-09-24

TODAY

Page 41: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Data volume under control

2014-09-24

TODAY

WEEK

Page 42: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Data volume under control

2014-09-24 2014-09-25

TODAY

WEEK

Page 43: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Data volume under control

2014-09-24 2014-09-25 2014-09-26

TODAY

WEEK

Page 44: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Monitoring

Page 45: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Monitoring

Page 46: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Monitoring

Page 47: From zero to hero - Easy log centralization with Logstash and Elasticsearch

SPM

http://sematext.com/spm/

Page 48: From zero to hero - Easy log centralization with Logstash and Elasticsearch

SPM

http://sematext.com/spm/

Page 49: From zero to hero - Easy log centralization with Logstash and Elasticsearch

SPM

http://sematext.com/spm/

Page 50: From zero to hero - Easy log centralization with Logstash and Elasticsearch

SPM

http://sematext.com/spm/

Page 51: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Here comes Logstash

Unstructured

Page 52: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Here comes Logstash

Unstructured

Page 53: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Here comes Logstash

Unstructured Documents

Page 54: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Processing example 127.0.0.1 - - [05/Feb/2014:17:11:55 +0000] "GET /css/main.css HTTP/1.1" 200 140 "http://www.onet.pl"

"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"

Page 55: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Processing example 127.0.0.1 - - [05/Feb/2014:17:11:55 +0000] "GET /css/main.css HTTP/1.1" 200 140 "http://www.onet.pl"

"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"

Page 56: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Processing example 127.0.0.1 - - [05/Feb/2014:17:11:55 +0000] "GET /css/main.css HTTP/1.1" 200 140 "http://www.onet.pl"

"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"

{ "host" : "127.0.0.1", "@timestamp" : "2014-02-05T17:11:55+0000", ... "verb" : "GET" }

Page 57: From zero to hero - Easy log centralization with Logstash and Elasticsearch

How does it look?

Page 58: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Of course you can scale

Page 59: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Logstash input

input { file { path => "/var/log/apache/apache.log" type => "access_apache_log" start_position => "beginning" } }

Page 60: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Grok

filter { if [type] == "access_apache_log" { grok { match => { "message" => "%{COMBINEDAPACHELOG}" } } } }

Page 61: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Logstash output

output { elasticsearch { host => "localhost" port => 9200 index => "logs_%{+YYYY.MM.dd}" protocol => "http" manage_template => true } }

Page 62: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Sample Logstash-forwarder config

{ "network": { "servers": [ "localhost:5043" ], "timeout": 15 }, "files": [ { "paths": [ "/var/log/apache/apache*.log" ], "fields": { "type": "access_apache_log" } } ] }

Page 63: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Sample Logstash-forwarder config

{ "network": { "servers": [ "localhost:5043" ], "timeout": 15 }, "files": [ { "paths": [ "/var/log/apache/apache*.log" ], "fields": { "type": "access_apache_log" } } ] }

Logstash side: input { lumberjack { port => 5043 type => "access_apache_log" } }

Page 64: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Let’s try it

$ bin/logstash –f logstash-filter.conf

Page 65: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Let’s try it

$ bin/logstash –f logstash-filter.conf

$ curl 'localhost:9200/logs_2014-09-26/_search?pretty'

Page 66: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Let’s try it

$ bin/logstash –f logstash-filter.conf

$ curl 'localhost:9200/logs_2014-09-26/_search?pretty'

{ "took" : 3, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 3, "max_score" : 1.0, "hits" : [ { "_index" : "logs", "_type" : "access_apache_log", "_id" : "SI0BZw8BQ0uQNPtk9zfoOQ", "_score" : 1.0, "_source":{"message":"71.141.244.242 - kurt [18/May/2011:01:48:10 -0700] \"GET /admin HTTP/1.1\" 301 566 \"-\" \"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3\"","@version":"1","@timestamp":"2014-09-11T10:21:04.403Z","type":"access_apache_log","host":"developer-vb","path":"/home/gro/devops/apache3.log","clientip":"71.141.244.242","ident":"-","auth":"kurt","timestamp":"18/May/2011:01:48:10 -0700","verb":"GET","request":"/admin","httpversion":"1.1","response":"301","bytes":"566","referrer":"\"-\"","agent":"\"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3\""} }, { "_index" : "logs", "_type" : "access_apache_log", "_id" : "zyOc53uwQkegOQr-a3hwIQ", "_score" : 1.0, "_source":{"message":"98.83.179.51 - - [18/May/2011:19:35:08 -0700] \"GET /css/main.css HTTP/1.1\" 200 1837 \"http://www.safesand.com/information.htm\" \"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1\"","@version":"1","@timestamp":"2014-09-11T10:21:04.405Z","type":"access_apache_log","host":"developer-vb","path":"/home/gro/devops/apache3.log","clientip":"98.83.179.51","ident":"-","auth":"-","timestamp":"18/May/2011:19:35:08 -0700","verb":"GET","request":"/css/main.css","httpversion":"1.1","response":"200","bytes":"1837","referrer":"\"http://www.safesand.com/information.htm\"","agent":"\"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1\""} }, { "_index" : "logs", "_type" : "access_apache_log", "_id" : "evP0I--3TWOlDsQzalQtAw", "_score" : 1.0, "_source":{"message":"134.39.72.245 - - [18/May/2011:12:40:18 -0700] \"GET /favicon.ico HTTP/1.1\" 200 1189 \"-\" \"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2; .NET4.0C; .NET4.0E)\"","@version":"1","@timestamp":"2014-09-11T10:21:04.404Z","type":"access_apache_log","host":"developer-vb","path":"/home/gro/devops/apache3.log","clientip":"134.39.72.245","ident":"-","auth":"-","timestamp":"18/May/2011:12:40:18 -0700","verb":"GET","request":"/favicon.ico","httpversion":"1.1","response":"200","bytes":"1189","referrer":"\"-\"","agent":"\"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2; .NET4.0C; .NET4.0E)\""} } ] } }

Page 67: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Here comes Kibana

Page 68: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Looking for SaaS – Go Logsene

http://sematext.com/logsene

Page 69: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Looking for SaaS – Go Logsene

http://sematext.com/logsene

Page 70: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Logstash + Logsene in action

output { elasticsearch { host => "logsene-receiver.sematext.com" port => 80 index => "YOUR_TOKEN" protocol => "http" manage_template => false } }

http://sematext.com/logsene

Page 71: From zero to hero - Easy log centralization with Logstash and Elasticsearch

Short summary

http://www.soothetube.com/2013/12/29/thats-all-folks/

Page 72: From zero to hero - Easy log centralization with Logstash and Elasticsearch

We Are Hiring !

Dig Search ?

Dig Analytics ?

Dig Big Data ?

Dig Performance ?

Dig Logging ?

Dig working with and in open – source ?

We’re hiring world – wide !

http://sematext.com/about/jobs.html