Skip to content
Snippets Groups Projects
Name Last commit Last update
README.md

Installer Elasticsearch

Installation Elasticsearch & Kibana

Installer et lancer Elasticsearch

# Creer un network 
docker network create elastic 
# Télécharger l'image Elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.4.3
# Lancer l'image 
docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -t docker.elastic.co/elasticsearch/elasticsearch:8.4.3

Note : Durant le lancement dans le terminal ou dans Docker desktop vont apparaitre des informations suivantes :

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-> Elasticsearch security features have been automatically configured!
-> Authentication is enabled and cluster connections are encrypted.

->  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
  IvI2WWQ89b2jXfeFvDHN

->  HTTP CA certificate SHA-256 fingerprint:
  ae12d482d7f1e668c091d17d81e94b13f1d6ab45bb6afafd0c9de6a66fadbe57

->  Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMTkuMC4yOjkyMDAiXSwiZmdyIjoiYWUxMmQ0ODJkN2YxZTY2OGMwOTFkMTdkODFlOTRiMTNmMWQ2YWI0NWJiNmFmYWZkMGM5ZGU2YTY2ZmFkYmU1NyIsImtleSI6IlQwbG81SU1CNm9sMWo5bnN0YklrOjJsdXBWM0hPUU1pWmN4cl9JNGZ1elEifQ==

-> Configure other nodes to join this cluster:
* Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMTkuMC4yOjkyMDAiXSwiZmdyIjoiYWUxMmQ0ODJkN2YxZTY2OGMwOTFkMTdkODFlOTRiMTNmMWQ2YWI0NWJiNmFmYWZkMGM5ZGU2YTY2ZmFkYmU1NyIsImtleSI6IlVVbG81SU1CNm9sMWo5bnN0YkkzOktFbkRKYlVOVDhTMXQyMklSZDlEMncifQ==

  If you're running in Docker, copy the enrollment token and run:
  `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.4.3`
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ATTENTION Converser ses informations

  • Mot de passe pour votre user "elasticsearch"
  • Enrollment token pour Kibana
# Copier le certificat
docker cp es-node01:/usr/share/elasticsearch/config/certs/http_ca.crt .
# Lancer la commande 
curl --cacert http_ca.crt -u elastic https://localhost:9200

Cela va vous demander votre mot de passe, ce cera le mot de passe que vous avez sauvegardé précédemment

Réponse attendu : attendu1

### Installer Kibana
docker pull docker.elastic.co/kibana/kibana:8.4.2  
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.4.2

Pour accéder au Kibana, vous devez utiliser le login "elasticsearch" et le mot de passe

Partie 1 : Elastic Search dans Kibana et REST API

Aller dans Kibana, choisir Dev Tools>Console

Q1. Ajouter le nom d'une personne qui s'appelle Brayan dans l'index customer 1

Réponse attendu :

POST /customer/_doc/1
{
"name": "Brayan"
}

Q2. Ajouter l'age de 23 pour Brayan

POST /customer/_doc/1
{
"age": 23
}

Q3. Ajouter 10000 dans la balance de Brayan

POST /customer/_doc/1
{
"balance": 10000
}

Q4. Ouvrir un nouveau terminal, lancer la commande :

curl --cacert http_ca.crt -u elastic https://localhost:9200/customer/_doc/1

On doit pouvoir voir Brayan 23 ans avec 5000€ dans sa balance

Q5. Supprimer Brayan :)

Vous pouvez utiliser la ligne de commande ou Kibana comme vous voulez. Vérifiez bien que Brayan n'existe plus dans notre base de données

Note : Pour ajouter plusieurs documents en même temps, nous allons utiliser la requête _bulk

Q6. Ajouter le tableau suivant :

Q2

Q7. Trouver le client le plus jeune

Q8. Trouver la balance la plus élevé

Partie 2 : Agrégation de données et visualisation dans Kibana

Grâce aux visualisation, répondez aux questions suivants :

  • Le nombre total de vol
  • Le pourcentage de vol en retard
  • Le billet moyen le plus cher
  • Le jour où il y a eu le plus de vol
  • Le nombre de vol retardé avec un retard supérieur à 360 minutes

Partie 3 : API Elasticsearch