What is EC2 Instance?
- Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud.
- Access reliable, scalable infrastructure on demand. Scale capacity within minutes with SLA commitment of 99.99% availability.
- Provide secure compute for your applications. Security is built into the foundation of Amazon EC2 with the AWS Nitro System.
- Optimize performance and cost with flexible options like AWS Graviton-based instances, Amazon EC2 Spot instances, and AWS Savings Plans.
What is Grafana?
Grafana is an open-source data visualization and monitoring tool that integrates with complex data from sources like Prometheus, InfluxDB, Graphite, and ElasticSearch. Grafana lets you create alerts, notifications, and ad-hoc filters for your data while also making collaboration with your teammates easier through built-in sharing features.
Now let's jump into the project:-
Step 1 : Setting up EC2 Instance
Login to AWS console
Search for EC2 ,then click on Launch instance
Choose ubuntu as an operating system
Choose a key value pair or create a new one
Leave rest of the things as default and click on create instance
Now open command line write this command
ssh -i {path of key value pair} ubuntu@{public IP address of EC2 Instance}
Step 2 : Installing Grafana
- Download the Grafana GPG key with wget, then pipe the output to apt-key. This will add the key to your APT installation’s list of trusted keys, which will allow you to download and verify the GPG-signed Grafana package:
wget -q -O -https://packages.grafana.com/gpg.key | sudo apt-key add -
In this command, the option -q turns off the status update message for wget, and -O outputs the file that you downloaded to the terminal. These two options ensure that only the contents of the downloaded file are pipelined to apt-key.
- Next, add the Grafana repository to your APT sources:
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
- Refresh your APT cache to update your package lists:
sudo apt update
- You can now proceed with the installation:
sudo apt install grafana
- Once Grafana is installed, use systemctl to start the Grafana server:
sudo systemctl start grafana-server
- Next, verify that Grafana is running by checking the service’s status:
sudo systemctl status grafana-server
You will receive a output
- Lastly, enable the service to automatically start Grafana on boot:
sudo systemctl enable grafana-server
Step 3 : Running Grafana on browser
**Note: ** By default, Grafana will not be accessible to the external world due to the inbound traffic restriction by AWS. Open port 3000 in the inbound traffic rules as show below.
EC2 > Instances > Click on
In the bottom tabs -> Click on Security
Security groups
Add inbound traffic rules as shown in the image (you can just allow TCP 3000 as well, in my case, I allowed All traffic).
Login to Grafana using the below URL:
http://:3000 [You can get the ec2-instance-public-ip-address from your AWS EC2 console page]
Note: If you are not interested in allowing All Traffic to your EC2 instance
1. Delete the inbound traffic rule for your instance
2. Edit the inbound traffic rule to only allow custom TCP port 3000
After using the command
{ public IP address of Instance}.3000
You will see a welcome page of Grafana after that you can add username and password as admin and after that you will be successfully logged in to Grafana
That's a wrap.......