How to Install Elasticsearch and Kibana on Ubuntu 18.04 on Google Cloud Platform.
Elasticsearch is a RESTful search engine which stores all collected data.
Kibana is a web interface for visualizing the data stored in Elasticsearch.
In this guide you are going to learn how to install and set up Elasticsearch on Ubuntu 18.04 LTS on Google Compute Engine, install Kibana and configure it with Nginx to visualize the data stored in Elasticsearch through your domain name.
Prerequisites
- Standard Instance (3.75 GB RAM with Ubuntu 18.04 LTS OS).
- A running Compute Engine, see the Setting up Compute Engine Instance.
- Java 8 Install Oracle Java JDK on Google Cloud Ubuntu 18.04 LTS
- Domain name is pointed to your virtual machine.
- For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain
- Nginx and configure as a reverse proxy for Kibana Install Nginx and setup UFW
Install Elasticsearch
Once you have your Compute Engine set up with Ubuntu 18.04, Nginx and your domain is pointed to your VM Instance, you are ready to install and configure Elasticsearch.
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
sudo apt update
sudo apt install elasticsearch
Once Elasticsearch is installed you can restrict port 9200 from outside access by editing the elasticsearch.yml file
and uncomment the network.host
and replace the value with locahost
.
sudo nano /etc/elasticsearch/elasticsearch.yml
So it looks looks like this..
network.host: localhost
Hit Ctrl+X
followed by Y
and Enter
to save the file and exit.
Now start and enable Elasticsearch on server boot.
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
Now make sure your Elasticsearch service is running.
sudo systemctl status elasticsearch
Test your installation by sending a HTTP request.
curl -X GET "localhost:9200"
You will get a response with name, cluster_name, cluster_uuid, version.
Now Elasticsearch is installed and running successfully, next we can install Kibana.
Install Kibana
sudo apt install kibana
Once Kibana is installed you can enable and start Kibana.
sudo systemctl enable kibana
sudo systemctl start kibana
As Kibana listens only on localhost
port 5601
, you need to setup Nginx reverse proxy to allow access through your Domain name.
Set up Nginx Reverse Proxy for Kibana
Create a new Nginx server block.
sudo nano /etc/nginx/sites-available/yourdomainname.com
Paste the following:
server {
listen 80;
server_name yourdomainname.com;
location / {
rewrite ^/(.*) /$1 break;
proxy_ignore_client_abort on;
proxy_pass http://localhost:5601;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
Hit Ctrl+X
followed by Y
and Enter
to save the file and exit.
Validate your Nginx configuration and restart it.
sudo nginx -t
sudo service nginx restart
Now Kibana dashboard is accessible via http://yourdomainname.com/status
Now Elasticsearch is configured and Kibana dashboard is set up using Nginx reverse proxy.
Leave a Reply
You must be logged in to post a comment.