Scrivere e leggere log con elastic
-
Upload
massimiliano-arione -
Category
Technology
-
view
708 -
download
4
Transcript of Scrivere e leggere log con elastic
Scrivere e leggere log con Elastic
Roma 26 aprile 2016
naming things...
Lo stack ELK
Lo stack Elastic
log
log
Problemi con i classici file di log1. sono destrutturati2. sono sparsi sul filesystem3. possono essere sparsi su macchine diverse4. possono essere sparsi su N macchine5. potrebbero essere molto grandi e contenere info di dominio
logstashhttps://www.elastic.co/products/logstash
Process Any Data, From Any Source
● centralizzare il processamento dei dati● normalizzare schemi e formati● estendere su formati personalizzati● aggiungere facilmente plugin
Installazione di logstashwget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-
key add -
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable
main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update && sudo apt-get install logstash
elasticsearchhttps://www.elastic.co/products/elasticsearch
Actionable Insight at Your Fingers
● Distribuito, scalabile, ad alta disponibilità● Ricerche e analisi in tempo reale● API RESTful
Installazione di elasticsearchecho "deb http://packages.elastic.co/elasticsearch/2.x/debian stable
main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update && sudo apt-get install elasticsearch
Configurazione /etc/logstash/conf.d/logstash.conf
input {
gelf {
type => gelf
}
}
output {
elasticsearch {
hosts => [‘localhost’]
}
}
Configurazione /etc/logstash/conf.d/logstash.conf
input {
file {
type => apache-access
path => /var/log/apache/access.log
}
}
filter {
}
MonologGelfMessageFormatter / GelfHandler
Symfony
monolog:
handlers:
stash:
type: gelf
publisher: { hostname: 127.0.0.1 }
level: debug
formatter: monolog.formatter.gelf_message
composer require graylog2/gelf-php
log
$this->logger->info(‘fooEvent’, [‘foo’ => ‘bar’, ‘user’ => ‘pippo’])
[2016-04-26 19:16:23] app.INFO: fooEvent {‘foo’: ‘bar’, ‘user’: ‘pippo’} []
Kibanahttps://www.elastic.co/products/kibana
See the Value in Your Data
● Analisi e visualizzazione flessibile ● Sintesi e grafici in tempo reale● Interfaccia intuitiva per gli utenti● Cruscotti condisivibili ed embeddabili
Installazione di kibanaecho "deb http://packages.elastic.co/kibana/4.4/debian stable main" |
sudo tee -a /etc/apt/sources.list.d/kibana.list
sudo apt-get update && sudo apt-get install kibana
configurazione# kibana.yml
server.port: 5601
server.host: "127.0.0.1"
configurazione
<VirtualHost *:80>
ServerName kibana.example.org
ProxyPass / http://localhost:5601/
ProxyPassReverse / http://localhost:5601/
<Location />
AuthType Basic
[...]
</Location>
</VirtualHost>