π― Installing and Configuring the Kibana Dashboard π
Kibana is a powerful visualization tool that works with Elasticsearch to help you explore, analyze, and visualize data in real time. It provides intuitive dashboards, charts, and search capabilities for your log and metric data.
π Step 1: Install Kibana π β
sudo apt install kibana
π Step 2: Enable and Start Kibana Service β‘β
sudo systemctl enable kibana
sudo systemctl start kibana
By default, Kibana listens only on localhost (127.0.0.1). To access it externally, youβll need to set up a reverse proxy using Nginx.
π Step 3: Set Up Nginx as a Reverse Proxy πβ
Ensure Nginx is installed:
sudo apt install nginx
π Step 4: Create an Administrative Kibana User πβ
Weβll create a username and password to secure access to Kibana via Nginx.
echo "asifkibana:`openssl passwd -apr1`" | sudo tee -a /etc/nginx/htpasswd.users
π‘ Replace asifkibana with your desired username and set a strong password when prompted.
Example password:
Kibana@123(β οΈ Do not use this in production.)
π Step 5: Configure Nginx Reverse Proxy π₯β
Create a new Nginx configuration file:
sudo vi /etc/nginx/sites-available/elk.asifahmadkhan.com.conf
Add the following configuration:
server {
listen 80;
server_name elk.asifahmadkhan.com;
access_log /var/log/nginx/elk.asifahmadkhan.com_access.log;
error_log /var/log/nginx/elk.asifahmadkhan.com_error.log;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
π Step 6: Enable and Restart Nginx πβ
sudo ln -s /etc/nginx/sites-available/elk.asifahmadkhan.com.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
π Step 7: Allow Nginx Traffic Through Firewall π₯β
sudo ufw allow 'Nginx Full'
π Final Step: Access Kibana β β
Open your browser and visit:
http://elk.asifahmadkhan.com
Enter your username and password created earlier to access the Kibana dashboard.
πΉ Ensure your DNS
elk.asifahmadkhan.compoints to your serverβs IP. πΉ For added security, enable HTTPS using an SSL certificate (e.g., Letβs Encrypt).
βοΈ If You Canβt Access via IP:5601β
Edit your Kibana configuration file:
sudo vi /etc/kibana/kibana.yml
Change this line:
server.host: "localhost"
to:
server.host: "0.0.0.0"
π Example Kibana Configuration Fileβ
root@ip-172-31-11-126:/home/ubuntu# cat /etc/kibana/kibana.yml
# For more configuration options see the configuration guide for Kibana
elasticsearch.hosts: ["https://127.0.0.1:9200"]
elasticsearch.username: "kibana_system"
elasticsearch.password: "9nv-mDIWEwz*Uf*k0oD_"
elasticsearch.ssl.verificationMode: none
π Logsβ
Kibana logs are stored in:
/var/log/kibana/kibana.log
Check if Kibana is running:
ss -ltnp | grep 5601
curl -I http://127.0.0.1:5601
π§ Elasticsearch Integration with Kibanaβ
Create Enrollment Token:β
/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
Get Verification Code:β
sudo /usr/share/kibana/bin/kibana-verification-code
π Verify Elasticsearch Credentialsβ
Check if your Elasticsearch username and password work:
curl -u YOUR_USERNAME:YOUR_PASSWORD -k "https://ELASTICSEARCH_HOST:9200/_cluster/health?pretty"
Example:
curl -u elastic:Sr7iGymZ*_f41jb_Ybuf -k "https://localhost:9200/_cluster/health?pretty"
π Reset Elasticsearch Passwordβ
If needed, reset the elastic user password:
sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic