elk devops

41
ELK, a real case study Alessandro Mazzoli Sysadmin@Ideato [email protected] Paolo Tonin Sysadmin@Ideato [email protected]

Upload: ideato

Post on 17-Jul-2015

275 views

Category:

Software


7 download

TRANSCRIPT

Page 1: Elk devops

ELK, a real case study

Alessandro Mazzoli Sysadmin@Ideato [email protected]

Paolo Tonin Sysadmin@Ideato [email protected]

Page 2: Elk devops

What is ELK stack?

Elasticsearch Logstash Kibana

http://en.wikipedia.org/wiki/Elk

Page 3: Elk devops

Logging problems(especially if you are a small company)

Page 4: Elk devops

Centralize, index, archive

Page 5: Elk devops

Law constraints

Page 6: Elk devops

Many log structures

Page 7: Elk devops

Log As a Service?!?! Pretty expensive

Page 8: Elk devops

Log analysis is hard for non technical people

Page 9: Elk devops

cat access.log | cut -d' ' -f1 | sort | uniq

Page 10: Elk devops
Page 11: Elk devops

People don’t pay attention

to boring things.- Brain Rules by John Medina

Page 12: Elk devops
Page 13: Elk devops

Major logging systems

Pro

Page 14: Elk devops

Why ELK, a case studyWeb Tier

ApacheNginx Proxy

MySQL DB

Proxy FE Database BE

NFS shared filesystem

Page 15: Elk devops

We need to scale Web Tier

Page 16: Elk devops

Why ELK, a case study

Nginx proxy LB

Apache web1 MySQL DB

Memcached, Logstash

Web TierProxy FE Database BE

Apache web2

NFS shared filesystem

Page 17: Elk devops

Nginx proxy LB

Apache web1 MySQL DB

Memcached, Logstash

Web TierProxy FE Database BE

Apache web2

NFS shared filesystem

Why ELK, a case study

local log

local log

Page 18: Elk devops

ELK architecture

Server 1

Log File

Logstash Shipper

Redis

Application

Logstash Indexer

Elasticsearch

Page 19: Elk devops

Scale out any components!

Page 20: Elk devops

Redis

Logstash Indexer

Redis

Redis

Redis

ElasticsearchElasticsearch

Server 2

Logstash Shipper

Server 1

Logstash Shipper

Page 21: Elk devops

Logstash configurationinput {!

}

filter {!

}

output {!

}

Where log come from?

Page 22: Elk devops

Logstash configurationinput {!

}

filter {!

}

output {!

}

How we threat them ?

Where log come from?

Page 23: Elk devops

Logstash configurationinput {!

}

filter {!

}

output {!

}Where will be stored?

How we threat them ?

Where log come from?

Page 24: Elk devops

Example configurationinput { file { path => "/var/log/messages" type => "syslog" } file { path => "/var/log/apache/access.log" type => “apache-access" }}

Page 25: Elk devops

Example configurationfilter { if [type] =~ "access" { mutate { replace => { "type" => “apache-access” } } grok { match => { "message" => "%{COMBINEDAPACHELOG}" } } } date { match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"] } }}

Page 26: Elk devops

Example configurationoutput { elasticsearch { host => localhost }}

Page 27: Elk devops

“How can I collect and consult my application Magento log?”

Page 28: Elk devops

Custom filter

Page 29: Elk devops

Grok

It’s is currently the best way in logstash to parse crappy unstructured log data into something structured and queryable

- http://logstash.net/docs/1.4.2/filters/grok

Page 30: Elk devops

https://github.com/ideatosrl/logstash-magento-filter

input { file { path => “/var/www/magento/var/log/*.log" type => "magento" codec => plain { charset => "ISO-8859-1" } }}

Logstash Shipper

Page 31: Elk devops

https://github.com/ideatosrl/logstash-magento-filter

filter { if [type] == "magento" { grok { match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{DATA:syslog_program}"} add_field => [ "received_at", "%{@timestamp}" ] } }}

Logstash Shipper

Page 32: Elk devops

https://github.com/ideatosrl/logstash-magento-filter

output { redis { host => “REDIS_IP" data_type => "list" key => "logstash" }}

Logstash Shipper

Page 33: Elk devops

https://github.com/ideatosrl/logstash-magento-filter

input { redis { host => "REDIS_IP" type => "redis-input" data_type => “list" key => "logstash" }}output { elasticsearch { host => “ES_PUBLIC_IP” protocol => "http" manage_template => false index => "logstash-%{+YYYY.MM.dd}" }}

Logstash Indexer

Page 34: Elk devops

Before…2015-03-30T15:25:34.867Z SoapFault exception: [soap:Client] Server was unable to read request. ---> There is an error in XML document (2, 439). ---> Input string was not in a correct format. in /var/www/magento/vendor/connect20/MailUp/app/code/local/MailUp/MailUpSync/Model/Observer.php:158

Page 35: Elk devops

{ "_index": "logstash-2015.03.30", "_type": "magento", "_id": "AUxrSbc5UWx9I25Cgios", "_score": null, "_source": { "message": "SoapFault exception: [soap:Client] Server was unable to read request. ---> There is an error in XML document (2, 435). ---> Input string was not in a correct format. in /var/www/magento/vendor/connect20/MailUp/app/code/local/MailUp/MailUpSync/Model/Observer.php:158", "@version": "1", "@timestamp": "2015-03-30T15:25:34.867Z", "type": "magento", "host": "web2", "path": "/var/www/magento/var/log/exception.log", },}

Page 36: Elk devops

And display it!

Page 37: Elk devops

“Should I use ELK?”

Page 38: Elk devops

PRO• Easy to install

!

• Opensource !

• Not only web logs! !

• Many output filters; S3, Google Big Query, MongoDb etc…

Page 39: Elk devops

ConclusionsCONS• Many moving parts, each part has

their problems and issues !

• Quickly evolution, prepare yourself to upgrade frequently !

• Out-of-the-box configurations are not suitable for medium/large deployment

Page 40: Elk devops

Links

http://www.ideato.it/technical-articles/integrazione-logstash-magento

https://github.com/ideatosrl/logstash-magento-filter

https://www.youtube.com/watch?v=RuUFnog29M4

http://logstash.net

http://elastic.co

Page 41: Elk devops

Questions?!?