Before we start, make sure you have the following:
An AWS account with an EC2 instance running Ubuntu.
SSH access to your EC2 instance.
Basic knowledge of the Linux command line.
Step 1: Connect to Your EC2 Instance
To get started, connect to your Ubuntu-based EC2 instance via SSH. You can do this using the following command, replacing your-instance-ip
with the actual IP address of your EC2 instance:
ssh -i your-key.pem ubuntu@your-instance-ip
Step 2: Update and Upgrade
Once you're connected to your EC2 instance, it's a good practice to update the package list and upgrade the installed packages:
sudo apt update
sudo apt upgrade -y
Step 3: Install Grafana
Next, you'll need to install Grafana. You can do this by adding the Grafana APT repository and then installing the Grafana package:
sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install grafana
Step 4: Start and Enable Grafana
Once Grafana is installed, you can start the service and enable it to start at boot:
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
Step 5: Access the Grafana Web Interface
Grafana's web interface should now be accessible. By default, Grafana runs on port 3000. Open your web browser and navigate to http://your-instance-ip:3000
. You should see the Grafana login page.
Username: admin
Password: admin (You'll be prompted to change this password upon first login)
Step 6: Configure Data Sources
To use Grafana effectively, you'll need to configure data sources. Grafana supports a wide range of data sources, including popular databases like MySQL, PostgreSQL, and cloud services like AWS CloudWatch.
Log in to Grafana with your new password.
Click on the gear icon (⚙️) on the left sidebar to open the Configuration menu.
Select "Data Sources."
Click the "Add data source" button.
Choose your data source type and configure the connection settings accordingly.
Save and test the data source.
Step 7: Create Dashboards
With your data source configured, you can now create dashboards to visualize your data. Grafana provides a user-friendly dashboard editor that allows you to build custom visualizations and panels.
Click the "+" icon on the left sidebar to create a new dashboard.
Click "Add new panel" to start building your visualization.
Customize your panel by selecting the data source and configuring the query.
Continue adding panels to your dashboard as needed.
Step 8: Explore and Share
You've successfully set up Grafana on your AWS EC2 instance, configured data sources, and created dashboards. Now, you can explore your data and share your dashboards with your team.