Newer
Older
# Installation Elasticsearch & Kibana
## Installer et lancer Elasticsearch
``` bash
# 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
``` bash
# 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 :

``` bash
### 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
#### Q1. Ajouter le nom d'une personne qui s'appelle Brayan dans l'index customer 1
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
> docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.4.2
docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.4.2
Tester la configuration :
- Vérifier que l'instance est up depuis le navigateur ou via curl ou postman : http://127.0.0.1:9200. La réponse doit ressemble à cela :
>{
> "name" : "elasticsearch-fd9946598-4lnrm",
> "cluster_name" : "docker-| ",
> "cluster_uuid" : "5lqmnamcTeqrRj4AFi9_8g",
> "version" : {
> "number" : "7.15.2",
> "build_flavor" : "default",
> "build_type" : "docker",
> "build_hash" :"93d5a7f6192e8a1a12e154a2b81bf6fa7309da0c",
> "build_date" : "2021-11-04T14:04:42.515624022Z",
> "build_snapshot" : false,
> "lucene_version" : "8.9.0",
> "minimum_wire_compatibility_version" : "6.8.0",
> "minimum_index_compatibility_version" : "6.0.0-beta1"
>},
>"tagline" : "You Know, for Search"
### 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
<strong>Note<strong>: Moyen pour intéragir avec Elastic ( Add,Update,Read,…)
* API elasticsearch (Python, Java, etc.)
* Avec les beats (metricbeat, filebeat, etc.)
* Sur l'écran Kibana en utilisant dev tools ou l’option "Upload * Data” en chargeant directement depuis un fichier
### Partie 1 : Elasticsearch
#### 1. 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
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 :

#### Q7. Trouver le client le plus jeune
#### Q8. Trouver la balance la plus élevé
#### 2. Ajouter l'age de 23 pour Brayan
#### 3. Ajouter 5000 dans la balance de Brayan
#### 4. Supprimer Brayan :)
Note : Pour ajouter plusieurs documents en même temps, nous allons utiliser la requête _bulk
#### 4. Ajouter le tableau suivant :

#### 5. Trouver le client le plus jeune
#### 6. Trouver la balance la plus élevé
### Partie 2 : Agrégation de données et visualisation dans Kibana
* 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