├── Intro to Elasticsearch and Kibana.pdf ├── README.md ├── docker-compose-directions.md └── docker-compose.yml /Intro to Elasticsearch and Kibana.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/7b4711961f73f04526846d1c8ee9a6f66699d7e8/Intro to Elasticsearch and Kibana.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Beginner's Crash Course to Elastic Stack Series 2 | ## Part 1: Intro to Elasticsearch & Kibana 3 | 4 | Welcome to the Beginner's Crash Course to Elastic Stack! 5 | 6 | This repo contains all resources shared during workshop Part 1: Intro to Elasticsearch and Kibana. 7 | 8 | By the end of this workshop, you will be able to: 9 | 10 | - understand a use case of Elasticsearch and Kibana 11 | - understand the basic architecture of Elasticsearch 12 | - perform CRUD(Create, Read, Update, and Delete) operations with Elasticsearch and Kibana 13 | 14 | ## Resources 15 | 16 | [Beginner's Crash Course to Elastic Stack Table of Contents](https://github.com/LisaHJung/Beginners-Crash-Course-to-the-Elastic-Stack-Series) 17 | 18 | This workshop is a part of the Beginner's Crash Course to Elastic Stack series. Check out this table contents to access all the workshops in the series thus far. This table will continue to get updated as more workshops in the series are released! 19 | 20 | [Free Elastic Cloud Trial](https://www.elastic.co/cloud/cloud-trial-overview/30-days?ultron=community-beginners-crash-course-May2022+&hulk=30d) 21 | 22 | [Instructions](https://dev.to/lisahjung/beginner-s-guide-to-setting-up-elasticsearch-and-kibana-with-elastic-cloud-1joh) on how to access Elasticsearch and Kibana on Elastic Cloud 23 | 24 | [Instructions](https://dev.to/elastic/downloading-elasticsearch-and-kibana-macos-linux-and-windows-1mmo) for downloading Elasticsearch and Kibana 25 | 26 | [Alternative installation using Docker](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/docker-compose.yml) 27 | 28 | One of our AMAZING community member @h3ct0rjs has shared how you can run Elasticsearch and Kibana using Docker! Refer to this [link](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/docker-compose-directions.md) for his awesome step by step directions. Thank you so much @h3ct0rjs!! 29 | 30 | [Presentation](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/Intro%20to%20Elasticsearch%20and%20Kibana.pdf) 31 | 32 | [Video recording](https://www.youtube.com/watch?v=gS_nHTWZEJ8&t=8s) of the workshop 33 | 34 | [Mini Beginner's Crash Course to Elasticsearch & Kibana playlist](https://ela.st/mini-beginners-crash-course) 35 | 36 | Do you prefer learning by watching shorter videos? Check out this playlist to watch short clips of beginner's crash course full length workshops. Part 1 workshop is broken down into episodes 1-6. Season 2 clips will be uploaded here in the future! 37 | 38 | [Blog](https://dev.to/lisahjung/beginner-s-guide-to-elasticsearch-4j2k) Beginner's guide to Elasticsearch 39 | 40 | [Blog](https://dev.to/lisahjung/beginner-s-guide-to-performing-crud-operations-with-elasticsearch-kibana-1h0n) Beginner's guide to performing CRUD operations with Elasticsearch and Kibana 41 | 42 | [Elastic America Virtual Chapter](https://community.elastic.co/amer-virtual/) Want to attend live workshops? Join the Elastic America Virtual Chapter to get the deets! 43 | 44 | [What's next?](https://github.com/LisaHJung/Part-2-Understanding-the-relevance-of-your-search-with-Elasticsearch-and-Kibana-) Eager to continue your learning after mastering the concept from this workshop? Move on to Part 2: Understanding the relevance of your search with Elasticsearch and Kibana [here](https://github.com/LisaHJung/Part-2-Understanding-the-relevance-of-your-search-with-Elasticsearch-and-Kibana-)! 45 | 46 | ## Getting information about cluster and nodes 47 | Syntax: 48 | ``` 49 | GET _API/parameter 50 | ``` 51 | ### Get info about cluster health 52 | ``` 53 | GET _cluster/health 54 | ``` 55 | Expected response from Elasticsearch: 56 | 57 | ![image](https://user-images.githubusercontent.com/60980933/101955613-64bd9000-3bbb-11eb-89da-564dd8680155.png) 58 | 59 | ### Get info about nodes in a cluster 60 | ``` 61 | GET _nodes/stats 62 | ``` 63 | Expected response from Elasticsearch: 64 | 65 | ![image](https://user-images.githubusercontent.com/60980933/101932662-5742de80-3b98-11eb-941c-7b654b16858c.png) 66 | 67 | ## Performing CRUD operations 68 | 69 | ## C - Create 70 | ### Create an index 71 | Syntax: 72 | ``` 73 | PUT Name-of-the-Index 74 | ``` 75 | Example: 76 | ``` 77 | PUT favorite_candy 78 | ``` 79 | 80 | Expected response from Elasticsearch: 81 | 82 | ![image](https://user-images.githubusercontent.com/60980933/101956137-5459e500-3bbc-11eb-823d-9a6871924afd.png) 83 | 84 | #### Index a document 85 | When indexing a document, both HTTP verbs `POST` or `PUT` can be used. 86 | 87 | 1) Use POST when you want Elasticsearch to autogenerate an id for your document. 88 | 89 | Syntax: 90 | ``` 91 | POST Name-of-the-Index/_doc 92 | { 93 | "field": "value" 94 | } 95 | ```` 96 | Example: 97 | ``` 98 | POST favorite_candy/_doc 99 | { 100 | "first_name": "Lisa", 101 | "candy": "Sour Skittles" 102 | } 103 | ``` 104 | Expected response from Elasticsearch: 105 | ![image](https://user-images.githubusercontent.com/60980933/101933971-2d8ab700-3b9a-11eb-99a4-7d34b9819050.png) 106 | 107 | 2) Use PUT when you want to assign a specific id to your document(i.e. if your document has a natural identifier - purchase order number, patient id, & etc). 108 | For more detailed explanation, check out this [documentation](https://www.elastic.co/guide/en/elasticsearch/guide/current/index-doc.html) from Elastic! 109 | 110 | Syntax: 111 | ``` 112 | PUT Name-of-the-Index/_doc/id-you-want-to-assign-to-this-document 113 | { 114 | "field": "value" 115 | } 116 | ``` 117 | Example: 118 | ``` 119 | PUT favorite_candy/_doc/1 120 | { 121 | "first_name": "John", 122 | "candy": "Starburst" 123 | } 124 | ``` 125 | ### _create Endpoint 126 | When you index a document using an id that already exists, the existing document is overwritten by the new document. 127 | If you do not want a existing document to be overwritten, you can use the _create endpoint! 128 | 129 | With the _create Endpoint, no indexing will occur and you will get a 409 error message. 130 | 131 | Syntax: 132 | ``` 133 | PUT Name-of-the-Index/_create/id-you-want-to-assign-to-this-document 134 | { 135 | "field": "value" 136 | } 137 | ``` 138 | Example: 139 | ``` 140 | PUT favorite_candy/_create/1 141 | { 142 | "first_name": "Finn", 143 | "candy": "Jolly Ranchers" 144 | } 145 | ``` 146 | 147 | Expected response from Elasticsearch: 148 | 149 | ![image](https://user-images.githubusercontent.com/60980933/101937947-cf60d280-3b9f-11eb-8341-316ec4a69b35.png) 150 | 151 | ## R - READ 152 | ### Read a document 153 | Syntax: 154 | ``` 155 | GET Name-of-the-Index/_doc/id-of-the-document-you-want-to-retrieve 156 | ``` 157 | Example: 158 | ``` 159 | GET favorite_candy/_doc/1 160 | ``` 161 | Expected response from Elasticsearch: 162 | 163 | ![image](https://user-images.githubusercontent.com/60980933/101935925-0d102c00-3b9d-11eb-9620-1b642364ef6a.png) 164 | 165 | ## U - UPDATE 166 | ### Update a document 167 | 168 | If you want to update fields in a document, use the following syntax: 169 | ``` 170 | POST Name-of-the-Index/_update/id-of-the-document-you-want-to-update 171 | { 172 | "doc": { 173 | "field1": "value", 174 | "field2": "value", 175 | } 176 | } 177 | ``` 178 | Example: 179 | ``` 180 | POST favorite_candy/_update/1 181 | { 182 | "doc": { 183 | "candy": "M&M's" 184 | } 185 | } 186 | ``` 187 | Expected response from Elasticsearch: 188 | 189 | ![image](https://user-images.githubusercontent.com/60980933/101938690-05528680-3ba1-11eb-8eec-8e2dce678405.png) 190 | 191 | ## D- DELETE 192 | ### Delete a document 193 | 194 | Syntax: 195 | ``` 196 | DELETE Name-of-the-Index/_doc/id-of-the-document-you-want-to-delete 197 | ``` 198 | Example: 199 | ``` 200 | DELETE favorite_candy/_doc/1 201 | ``` 202 | Expected response from Elasticsearch: 203 | ![image](https://user-images.githubusercontent.com/60980933/101939174-dab4fd80-3ba1-11eb-93fe-de682853bae4.png) 204 | 205 | ## Take Home Assignment 206 | 1. Create an index called `destinations`. 207 | 2. Pick five dream travel destinations. For each destination, index a document containing the name and the country. 208 | 3. Read(GET) each document to check the content of the document. 209 | 4. Update a field of a document. 210 | 5. Read(GET) the updated document to ensure that the field has been updated. 211 | 6. Delete a document of one place. 212 | 7. Copy and paste the following request to return all documents from the `destinations` index. 213 | This is a great way to check whether all the CRUD operations you have performed thus far have worked! 214 | ``` 215 | GET destinations/_search 216 | { 217 | "query": { 218 | "match_all": {} 219 | } 220 | } 221 | ``` 222 | -------------------------------------------------------------------------------- /docker-compose-directions.md: -------------------------------------------------------------------------------- 1 | Related Resource 2 | - [docker-compose.yml](https://github.com/LisaHJung/Part-1-Intro-to-Elasticsearch-and-Kibana/blob/main/docker-compose.yml) 3 | 4 | For this Beginner's Crash Course, you can also use Docker to run Elasticsearch and Kibana this is not showed in the youtube video but it is optional and another popular way to install the software. You're going to find a docker-compose file that is going to deploy and install both Docker images using the following version. 5 | 6 | - elasticsearch:7.11.1 7 | - kibana:7.11.1 8 | 9 | In order to be able to run this, you will need to have installed: 10 | 11 | - [Docker](https://docs.docker.com/desktop/linux/) or [Docker Desktop](https://docs.docker.com/desktop/). 12 | - [Docker Compose](https://docs.docker.com/compose/). 13 | 14 | Install Elasticsearch and Kibana by using the following command: 15 | 16 | ```sh 17 | docker-compose up -d 18 | ``` 19 | 20 | The previous command is going to spin up two docker containers that will be in the same Docker network and in detached mode. With this, you will be able to open the following urls : 21 | 22 | * http://localhost:5601/ - Kibana Web UI interface 23 | * http://localhost:9200/ - Elastic Search API 24 | 25 | If you want to check the logs : 26 | ```sh 27 | docker-compose logs elasticsearch 28 | ``` 29 | for Kibana : 30 | ```sh 31 | docker-compose logs kibana 32 | ``` 33 | If you want to stop Elasticsearch and Kibana, you will need to run the following command : 34 | ```sh 35 | docker-compose stop 36 | ``` 37 | If you want to stop and destroy the docker services : 38 | 39 | ```sh 40 | docker-compose down 41 | ``` 42 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | elasticsearch: 3 | image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1 4 | container_name: elasticsearch 5 | #build: . 6 | ports: 7 | - '9200:9200' 8 | - '9300:9300' 9 | environment: 10 | discovery.type: single-node 11 | ES_JAVA_OPTS: -Xmx512m -Xms512m 12 | node.name: es01 13 | cluster.name: elasticsearch 14 | volumes: 15 | - ./elastic/data:/usr/share/elasticsearch/data 16 | networks: 17 | - elasticnet 18 | 19 | kibana: 20 | image: docker.elastic.co/kibana/kibana:7.11.1 21 | container_name: kibana 22 | ports: 23 | - '5601:5601' 24 | - '9600:9600' 25 | environment: 26 | SERVERNAME: kibana 27 | ELASTICSEARCH_HOSTS: http://elasticsearch:9200 28 | ES_JAVA_OPTS: -Xmx512m -Xms512m 29 | networks: 30 | - elasticnet 31 | depends_on: 32 | - elasticsearch 33 | volumes: 34 | logvolume01: {} 35 | 36 | networks: 37 | elasticnet: {} 38 | 39 | 40 | --------------------------------------------------------------------------------