# 04 - Step-by-Step Guide to Setting Up ELK Locally

The ELK stack, consisting of Elasticsearch, Logstash, and Kibana, is a powerful set of open-source tools for searching, analyzing, and visualizing data in real time.

**Elasticsearch** is a distributed, RESTful search and analytics engine that centrally stores your data. It allows you to search and analyze large volumes of data quickly and in near real time.

**Logstash** is a server-side data processing pipeline that ingests data from multiple sources, transforms it, and then sends it to a “stash” like Elasticsearch.

**Kibana** lets users visualize data with charts and graphs in Elasticsearch. It provides visualization capabilities on top of the content indexed on an Elasticsearch cluster.

This guide will walk you through the process of setting up each component of the ELK stack on your local machine, allowing you to create a powerful data analysis platform. Whether you’re a developer looking to debug your application logs, or a business analyst seeking insights from your data, this guide will help you get up and running with the ELK stack. Let’s get started!

### <mark style="color:yellow;">Elasticsearch</mark>

1. **Download Elasticsearch**: Visit the official Elasticsearch website (<https://www.elastic.co/downloads/elasticsearch>) and download the appropriate version for your operating system.
2. **Install Elasticsearch**: Once the download is complete, extract the downloaded archive and move the Elasticsearch folder to your desired location.
3. **Configure Elasticsearch (Optional)**: You might want to configure Elasticsearch settings based on your requirements. The main configuration file is `elasticsearch.yml`, located in the config directory within the Elasticsearch installation folder. Here you can specify settings such as cluster name, node name, network settings, etc.
4. **Start Elasticsearch**: Open a terminal or command prompt window and navigate to the Elasticsearch bin directory. Execute the `elasticsearch` script or executable to start Elasticsearch. On Windows, you might need to run `elasticsearch.bat`.
5. **Verify Elasticsearch is Running**: Open a web browser and go to <http://localhost:9200/>. You should see a JSON response indicating that Elasticsearch is running along with some basic information about the cluster.

***

### <mark style="color:green;">Logstash</mark>

1. **Download Logstash**: Visit the official Logstash website (<https://www.elastic.co/downloads/logstash>) and download the appropriate version for your operating system.
2. **Install Logstash**: Once the download is complete, extract the ZIP contents to a local folder. For example, you can extract the contents to `C:\logstash\` if you’re using Windows.
3. **Configure JVM Settings (Optional)**: Edit the `C:\logstash\config\jvm.options` file. Change the `Xmx` and `Xms` memory settings to half of the available system memory. If you have 4GB of system memory, then the setting should look like the following:

```bash
-Xms2g
-Xmx2g
```

4. **Configure Logstash**: The main configuration file for Logstash is `logstash.yml`, located in the `config` directory within the Logstash installation folder. Here you can specify settings such as node name, path settings, etc.
5. **Create a Logstash Pipeline**: Create a file named `logstash-simple.conf` in the same directory as Logstash. Here’s an example configuration:

```bash
input { stdin { } }
output {
  elasticsearch {
    hosts => ["http://localhost:9200"]
    index => "my_index"
  }
  stdout { codec => rubydebug }
}
```

6. **Start Logstash**: Open a terminal or command prompt window, navigate to the Logstash bin directory, and execute the `logstash` script or executable to start Logstash. On Windows, you might need to run `logstash.bat`.
7. **Verify Logstash is Running**: You can verify that Logstash is running and able to interact with Elasticsearch by checking your indices in Elasticsearch. You should see the index you specified in your Logstash configuration.

***

### <mark style="color:purple;">Kibana</mark>

1. **Download Kibana**: Visit the official Kibana website (<https://www.elastic.co/downloads/kibana>) and download the appropriate version for your operating system.
2. **Install Kibana**: Once the download is complete, extract the ZIP contents to a local folder. For example, you can extract the contents to `C:\kibana\` if you’re using Windows.
3. **Configure Kibana (Optional)**: The main configuration file for Kibana is `kibana.yml`, located in the `config` directory within the Kibana installation folder. Here you can specify settings such as Elasticsearch server URL, etc.
4. **Start Kibana**: Open a terminal or command prompt window, navigate to the Kibana bin directory, and execute the `kibana` script or executable to start Kibana. On Windows, you might need to run `kibana.bat`.
5. **Verify Kibana is Running**: Open a web browser and go to <http://localhost:5601/>. If Kibana is running successfully, you should see the Kibana home page.

Congratulations! You’ve successfully set up the ELK stack on your local machine. This powerful trio of Elasticsearch, Logstash, and Kibana will provide you with the ability to ingest and visualize your data in numerous ways.

Remember, the journey doesn’t stop here. There’s a vast amount of resources and community support available for the ELK stack, so continue exploring, learning, and building.

Whether you’re analyzing log files, crunching social media feeds, or gathering any other form of data, the ELK stack has got you covered.&#x20;
