
Introduction
Elastic Stack, also known as ELK, comprises three open-source programs: Elasticsearch, Logstash and Kibana. The stack is optimized for searching, analyzing, and visualization of large volumes of log data. The main components of the Elastic Stack are:
- Elasticsearch: This is the main component of the stack. It is a distributed RESTful search engine that stores and searches the text-based collected data.
 - Logstash: This data processing component collects and parses the incoming data before sending it to Elasticsearch for storage.
 - Kibana: This is the web interface dashboard used for searching and exploring the analyzed log data.
 - Beats: This is a lightweight transport agent with plugins used to aggregate application data from different servers and applications and then send the data to either Logstash or Elasticsearch for processing.
 
This article describes how to install Elastic Stack on Ubuntu 20.04 server.
Prerequisites
- Deploy a fully updated Vultr Ubuntu 20.04 Server.
 - Create a non-root user with sudo access.
 
1. Install Java and Nginx
Update system packages.
$ sudo apt updateInstall required packages.
$ sudo apt install wget curl gnupg2 -yTo run Elasticsearch, you require Java. Install Java.
$ sudo apt install openjdk-11-jdk -yVerify the installation.
$ java -versionKibana dashboard uses Nginx as a reverse proxy. Install Nginx webserver.
$ sudo apt install nginx -y
2. Install and Configure Elasticsearch
Install required packages.
$ sudo apt install apt-transport-https -yImport the Elasticsearch PGP signing key.
$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -Add Elasticsearch APT repository.
$ echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee –a /etc/apt/sources.list.d/elastic-7.x.listUpdate the system.
$ sudo apt updateInstall Elasticsearch.
$ sudo apt install elasticsearch -yEdit Elasticsearch configuration file.
$ sudo nano /etc/elasticsearch/elasticsearch.ymlUncomment the following lines.
#network.host: 192.168.0.1 #http.port: 9200Change value of
network.hosttolocalhostand add the following line in the Discovery section.discovery.type: single-nodeThe final file should have the lines as follows:
network.host: localhost http.port: 9200 discovery.type: single-nodeSave and close the file.
Reload the daemon.
$ sudo systemctl daemon-reloadStart the Elasticsearch service.
$ sudo systemctl start elasticsearchEnable Elasticsearch service to start at system startup.
$ sudo systemctl enable elasticsearchVerify that Elasticsearch is running and listening on port 9200.
$ curl -X GET "localhost:9200"
3. Install Logstash
Install Logstash.
$ sudo apt install logstash -yStart the Logstash service.
$ sudo systemctl start logstashEnable Logstash service to start at system startup.
$ sudo systemctl enable logstashVerify Logstash service status.
$ sudo systemctl status logstash
4. Install and Configure Kibana
Install Kibana.
$ sudo apt install kibana -yEdit the Kibana configuration file.
$ sudo nano /etc/kibana/kibana.ymlUncomment and modify the following lines from:
#server.port: 5601 #server.host: "localhost" #elasticsearch.hosts: ["http://localhost:9200"]To:
server.port: 5601 server.host: "0.0.0.0" elasticsearch.hosts: ["http://localhost:9200"]Save and close the file.
Start the Kibana service.
$ sudo systemctl start kibanaEnable Kibana service to start at system startup.
$ sudo systemctl enable kibanaAllow traffic on port
5601.$ sudo ufw allow 5601/tcp
5. Install and Configure Filebeat
Install Filebeat.
$ sudo apt install filebeat -yEdit the Filebeat configuration file.
$ sudo nano /etc/filebeat/filebeat.ymlComment out the following lines:
#output.elasticsearch: # Array of hosts to connect to. #hosts: ["localhost:9200"]Uncomment these lines in Logstash output section:
output.logstash: hosts: ["localhost:5044"]Save and exit the file.
Enable the Filebeat system module.
$ sudo filebeat modules enable systemLoad the index template.
$ sudo filebeat setup --index-management -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["localhost:9200"]'Start the Filebeat service.
$ sudo systemctl start filebeatEnable Filebeat service to start at system startup.
$ sudo systemctl enable filebeatVerify that Filebeat is shipping log files to Logstash for processing.
$ curl -XGET http://localhost:9200/_cat/indices?v
6. Access Kibana Web Interface
Open your web browser and access the Kibana web interface using the URL http://YourServerIP:5601. For example:
http://192.0.2.10:5601Conclusion
You have successfully installed Elastic Stack on your server. You can now access the main dashboard via the Kibana web interface.
More Information
For more information, please see: