How to Install Elastic Stack on Ubuntu 24.04 LTS

In this article, we will learn how to install the Elastic Stack on Ubuntu 24.04 LTS. The ELK Stack consists of Elasticsearch, Logstash, and Kibana, with Filebeat often used to ship logs to Logstash. This powerful combination is essential for centralized logging, data visualization, and real-time analysis. We will guide you through the installation and configuration of each component of the ELK stack and verify their setup.

Prerequisites

  • AWS Account with Ubuntu 24.04 LTS EC2 Instance.
  • At least 2 CPU cores and 4 GB of RAM for smooth performance.

Step #1:Install Java for Elastic Stack on Ubuntu 24.04 LTS

Start by updating your system’s package index.

sudo apt update
How to Install Elastic Stack on Ubuntu 24.04 LTS 1

Install the apt-transport-https package to access repository over HTTPS.

 sudo apt install apt-transport-https
How to Install Elastic Stack on Ubuntu 24.04 LTS 2

Elastic Stack components require Java. We will install OpenJDK 11, which is a widely used open-source implementation of the Java Platform.

sudo apt install openjdk-11-jdk -y
How to Install Elastic Stack on Ubuntu 24.04 LTS 3

After installation, verify that Java is correctly installed by checking its version.

java -version
How to Install Elastic Stack on Ubuntu 24.04 LTS 4

To ensure stack components can locate Java, we need to set the JAVA_HOME environment variable. Open the environment file.

sudo nano /etc/environment
How to Install Elastic Stack on Ubuntu 24.04 LTS 5

Add the following line at the end of the file.

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Apply the changes by reloading the environment.

source /etc/environment
How to Install Elastic Stack on Ubuntu 24.04 LTS 6

Verify that JAVA_HOME is set correctly.

echo $JAVA_HOME
How to Install Elastic Stack on Ubuntu 24.04 LTS 7

Step #2:Install ElasticSearch on Ubuntu 24.04 LTS

Elasticsearch is the core component of the ELK Stack, used for search and analytics. We need to import the public signing key and add the Elasticsearch APT repository to your system.

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
How to Install Elastic Stack on Ubuntu 24.04 LTS 8

Add the repository definition.

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
How to Install Elastic Stack on Ubuntu 24.04 LTS 9

Update the package lists again to include the new Elasticsearch repository.

sudo apt-get update
How to Install Elastic Stack on Ubuntu 24.04 LTS 10

Install Elasticsearch.

sudo apt-get install elasticsearch
How to Install Elastic Stack on Ubuntu 24.04 LTS 11

Start Elasticsearch and configure it to run at system startup.

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
How to Install Elastic Stack on Ubuntu 24.04 LTS 12

Verify that Elasticsearch is running.

sudo systemctl status elasticsearch

You should see output indicating that the service is active and running.

How to Install Elastic Stack on Ubuntu 24.04 LTS 13

Step #3:Configure Elasticsearch on Ubuntu 24.04 LTS

To allow external access to Elasticsearch, modify the configuration file.

sudo nano /etc/elasticsearch/elasticsearch.yml
How to Install Elastic Stack on Ubuntu 24.04 LTS 14

Find the network.host setting, uncomment it, and set it to 0.0.0.0 to bind to all available IP addresses and uncomment the discovery section to specify the initial nodes for cluster formation discovery.seed_hosts: []

How to Install Elastic Stack on Ubuntu 24.04 LTS 15

For a basic setup (not recommended for production), disable security features.

How to Install Elastic Stack on Ubuntu 24.04 LTS 16

Restart Elasticsearch to apply the changes.

sudo systemctl restart elasticsearch
How to Install Elastic Stack on Ubuntu 24.04 LTS 17

To confirm that Elasticsearch is set up correctly, send a test HTTP request using curl.

curl -X GET "localhost:9200"

You should see a JSON response.

How to Install Elastic Stack on Ubuntu 24.04 LTS 18

You can access it using browser with your Public IP address:9200 port which is a default port for Elasticksearch.

How to Install Elastic Stack on Ubuntu 24.04 LTS 19

Step #4:Install Logstash on Ubuntu 24.04 LTS

Logstash is used to process and forward log data to Elasticsearch. Install Logstash using following command.

sudo apt-get install logstash -y
How to Install Elastic Stack on Ubuntu 24.04 LTS 20

Start and enable Logstash.

sudo systemctl start logstash
sudo systemctl enable logstash
How to Install Elastic Stack on Ubuntu 24.04 LTS 21

Verify the service status.

sudo systemctl status logstash
How to Install Elastic Stack on Ubuntu 24.04 LTS 22

Step #5:Install Kibana on Ubuntu 24.04 LTS

Kibana provides a web interface for visualizing data from Elasticsearch. Install Kibana using following command.

sudo apt-get install kibana
How to Install Elastic Stack on Ubuntu 24.04 LTS 23

Start and enable the Kibana service.

sudo systemctl start kibana
sudo systemctl enable kibana
How to Install Elastic Stack on Ubuntu 24.04 LTS 24

Check the status of Kibana:

sudo systemctl status kibana
How to Install Elastic Stack on Ubuntu 24.04 LTS 25

Step #6:Configure Kibana on Ubuntu 24.04 LTS

To configure Kibana for external access, edit the configuration file.

sudo nano /etc/kibana/kibana.yml
How to Install Elastic Stack on Ubuntu 24.04 LTS 26

Uncomment and adjust the following lines to bind Kibana to all IP addresses and connect it to Elasticsearch.

server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
How to Install Elastic Stack on Ubuntu 24.04 LTS 27

Restart Kibana to apply the changes.

sudo systemctl restart kibana
How to Install Elastic Stack on Ubuntu 24.04 LTS 28

Access the Kibana interface by navigating to http://<your-server-ip>:5601 in your web browser. This will open the Kibana dashboard where you can start exploring your data.

How to Install Elastic Stack on Ubuntu 24.04 LTS 29

You can start by adding integrations or Explore on my own.

How to Install Elastic Stack on Ubuntu 24.04 LTS 30

Step #7:Install Filebeat on Ubuntu 24.04 LTS

Filebeat is a lightweight shipper used to forward and centralize log data. Install Filebeat using following command.

sudo apt-get install filebeat
How to Install Elastic Stack on Ubuntu 24.04 LTS 31

Open the Filebeat configuration file to send logs to Logstash.

sudo nano /etc/filebeat/filebeat.yml
How to Install Elastic Stack on Ubuntu 24.04 LTS 32

Comment out the Elasticsearch output section.

# output.elasticsearch:
# hosts: ["localhost:9200"]

Uncomment and configure the Logstash output section.

output.logstash:
hosts: ["localhost:5044"]
How to Install Elastic Stack on Ubuntu 24.04 LTS 33

Enable the system module, which collects log data from the local system.

sudo filebeat modules enable system
How to Install Elastic Stack on Ubuntu 24.04 LTS 34

Set up Filebeat to load the index template into Elasticsearch.

sudo filebeat setup --index-management -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["0.0.0.0:9200"]'
How to Install Elastic Stack on Ubuntu 24.04 LTS 35

Start and enable the Filebeat service.

sudo systemctl start filebeat
sudo systemctl enable filebeat
How to Install Elastic Stack on Ubuntu 24.04 LTS 36

Ensure Elasticsearch is receiving data from Filebeat by checking the indices.

curl -XGET "localhost:9200/_cat/indices?v"

You should see output indicating the presence of indices created by Filebeat.

How to Install Elastic Stack on Ubuntu 24.04 LTS 37

You can access it using browser using http://<your-server-ip>:9200/_cat/indices?v

How to Install Elastic Stack on Ubuntu 24.04 LTS 38

Conclusion:

In conclusion, we have successfully installed and configured the Elastic Stack on Ubuntu 24.04 LTS. This included setting up Elasticsearch for search and analytics, Logstash for data processing, Kibana for data visualization, and Filebeat for log shipping. The Elastic Stack provides a robust solution for centralized logging and data analysis, making it invaluable for monitoring and analyzing system performance and application logs.

Related Articles:

Python Script to Parse Nginx Log Files

Reference:

Elastic Stack official page

Prasad Hole

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap