156 lines
4.2 KiB
Markdown
156 lines
4.2 KiB
Markdown
---
|
|
title: Howto Stack Elastic
|
|
categories: nosql pack
|
|
---
|
|
|
|
Cette documentation décrit l'installation et la configuration de la suite Elastic, anciennement nommée **ELK** (Elasticsearch + Logstash + Kibana).
|
|
|
|
# Elasticsearch
|
|
|
|
## Installation
|
|
|
|
~~~
|
|
# wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
|
|
# echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" >> /etc/apt/sources.list.d/elastic.list
|
|
# apt install elasticsearch openjdk-7-jre
|
|
# systemctl enable elasticsearch && systemctl start elasticsearch
|
|
~~~
|
|
|
|
Pour plus de détails, voir [HowtoElasticsearch#installation]()
|
|
|
|
## Configuration
|
|
|
|
Préciser *node.name* dans le fichier `/etc/elasticsearch/elasticsearch.yml` :
|
|
|
|
~~~{.yaml}
|
|
node.name: bar
|
|
~~~
|
|
|
|
Pour plus détails, voir [HowtoElasticsearch#configuration]().
|
|
|
|
## Installation de quelques plugins
|
|
|
|
~~~
|
|
# /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head
|
|
# /usr/share/elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf
|
|
# chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/plugins/
|
|
~~~
|
|
|
|
Pour plus détails, voir [HowtoElasticsearch#plugins]().
|
|
|
|
## Utile
|
|
|
|
* les logs sont dans `/var/log/elasticsearch/_cluster_name_.log`
|
|
* l'interface **Head** est disponible sur http://127.0.0.1:9200/_plugin/head/
|
|
* l'interface **Kopf** est disponible sur http://127.0.0.1:9200/_plugin/kopf/
|
|
|
|
# Logstash
|
|
|
|
Logstash est un service qui récupère des données depuis des sources variées (ports TCP/UDP, fichiers…), les transforme et les renvois vers des sorties variées (fichiers, Elasticsearch, syslog…).
|
|
C'est un logiciel écrit en Ruby, qui tourne sur une JVM (grace à JRuby).
|
|
|
|
Documentation officielle : <https://www.elastic.co/guide/en/logstash/2.4/index.html>
|
|
|
|
## Installation
|
|
|
|
~~~
|
|
# echo "deb http://packages.elastic.co/logstash/2.4/debian stable main" | tee -a /etc/apt/sources.list.d/elastic.list
|
|
# apt install logstash
|
|
~~~
|
|
|
|
Dans `/etc/default/logstash` il faut penser à ajuster la ram allouée.
|
|
|
|
À ce stade, aucun "pipeline" Logstash n'est configuré.
|
|
Voir <https://www.elastic.co/guide/en/logstash/current/configuration.html>
|
|
|
|
## Démarrage
|
|
|
|
~~~
|
|
# systemctl start logstash
|
|
~~~
|
|
|
|
Pour que le démon soit géré automatiquement par systemd :
|
|
|
|
~~~
|
|
# systemctl enable logstash
|
|
~~~
|
|
|
|
# Kibana
|
|
|
|
Kibana est une interface de visualisation des donnes stockées dans Elasticsearch.
|
|
C'est un logiciel écrit principalement en NodeJS, où tout est embarqué dans un processus principal.
|
|
|
|
Documentation officielle : <https://www.elastic.co/guide/en/kibana/4.6/index.html>
|
|
|
|
## Installation
|
|
|
|
~~~
|
|
# echo "deb http://packages.elastic.co/kibana/4.6/debian stable main" | tee -a /etc/apt/sources.list.d/elastic.list
|
|
# apt install kibana
|
|
# /opt/kibana/bin/kibana plugin --install elastic/sense
|
|
# chown -R kibana: /opt/kibana
|
|
~~~
|
|
|
|
~~~
|
|
# vim /etc/logrotate.d/kibana
|
|
/var/log/kibana/*.log {
|
|
daily
|
|
rotate 7
|
|
copytruncate
|
|
compress
|
|
delaycompress
|
|
missingok
|
|
notifempty
|
|
}
|
|
~~~
|
|
|
|
## Démarrage
|
|
|
|
~~~
|
|
# systemctl start kibana
|
|
~~~
|
|
|
|
Pour que le démon soit géré automatiquement par systemd :
|
|
|
|
~~~
|
|
# systemctl enable kibana
|
|
~~~
|
|
|
|
## Utile
|
|
|
|
* l'interface principale est disponible sur <http://127.0.0.1:5601/>
|
|
* l'interface **Sense** est disponible sur <http://127.0.0.1:5601/app/sense>
|
|
|
|
## Proxy
|
|
|
|
Kibana ne gère pas d'authentification. Pour le rendre accessible de manière sécurisée, il est conseillé de le placer derrière un reverse proxy, par exemple Nginx.
|
|
|
|
~~~
|
|
upstream kibana {
|
|
server 127.0.0.1:5601 fail_timeout=0;
|
|
}
|
|
server {
|
|
charset utf-8;
|
|
|
|
# ajouter les règles d'authentification
|
|
|
|
listen _IP_PUBLIQUE_:80;
|
|
server_name _HOSTNAME_;
|
|
|
|
location / {
|
|
proxy_redirect off;
|
|
proxy_pass http://kibana/;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Server $host;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header Host $host;
|
|
}
|
|
}
|
|
~~~
|
|
|
|
# Conseils
|
|
|
|
* utiliser des certificats SSL (nativement géré par les logiciels) pour que les données circulent de manière chiffrée (surtout entre filebeat et logstash, car ça passe par Internet).
|