Creation of EC2 instance
Go to AWS console and create an EC2 instance with ubuntu OS.
Open all the below inbound ports to run specific services
Port: 9090
- PrometheusPort: 9100
- Node-ExporterPort: 3000
- GrafanaPort: 22
- SSH
After connecting to the instance, run the below command to check all entries of the “apt” packages list to see if any update is available for any package from all of the sources
sudo apt-get update
Installing and running prometheus
Prometheus Monitoring is a powerful tool for monitoring computer systems and applications. It continuously collects data about system performance and stores it in a time-series database that enables you to identify and diagnose problems, set up alerts, and optimize your systems for maximum efficiency.
Under the Prometheus section copy the compressed file link for Linux OS LTS version.
Come to the terminal and download the file.
wget <URL of the Copied .tar.gz File>
Now extract the prometheus compressed file
tar -xvfz <Promethus .tar.gz filename>
Change the directory after extracting Prometheus and you'll find these files
Now by shell following below command start the prometheus server
./prometheus
Now Prometheus server is running in the EC2 public IP with port 9090
http://<EC2 Public IP>:9090/
Installing and Running Node Exporter
The Node Exporter is an agent that gathers system metrics and exposes them in a format which can be ingested by Prometheus. The Node Exporter is a project that is maintained through the Prometheus project.
Under the node_exporter section copy the compressed file link for Linux OS.
Come to the duplicate tab terminal and download the file.
wget <URL of the Copied .tar.gz File>
Now extract the node-exporter compressed file
tar -xvfz <node-exporter .tar.gz filename>
Change the directory after extracting node-exporter and you'll find these files
Now by shell following below command start the node-exporter server
./node_exporter
Now Node-Exporter server is running in the EC2 public IP with port 9090
http://<EC2 Public IP>:9100/
Adding node exporter scrap_configs to prometheus as YAML format
In other Tab, Go to Prometheus folder and create a file named exported.yml using below command.
touch exporter.yml
Note: File name can be anything
Insert the below scrap configuration in exporter.yml and save it.
global: scrape_interval: 15s scrape_configs: - job_name: node-exporter static_configs: - targets: ['localhost:9100']
Note: Since my node exporter IP is same as Promethus server IP (as both are installed in one VM or EC2), I'm using localhost:9100 as 9100 is node-exporter port. We can add any number of node exporter in the following format,
static_configs:
- targets: ['localhost:9100', '172.163.0.0:9100', '19.168.0.54:9100']
Now run the prometheus server using the below command.
./prometheus --config-file=exporter.yml (or) ./promethus --config-file=<your_filename>.yml
Open the promethus server and Go to targets.
Refresh and you'll see node-exporter is UP.
Installing and Running Grafana
Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources.
Update the package info
sudo apt-get install -y apt-transport-https sudo apt-get install -y software-properties-common wget wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
Add stable repository of Grafana
echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
Update repository and Install Grafana
sudo apt-get update sudo apt-get install grafana-enterprise
Start Grafana server and enable it to run at boot time
sudo systemctl daemon-reload sudo systemctl start grafana-server sudo systemctl status grafana-server sudo systemctl enable grafana-server.service
Access grafana server in URL with port 3000
http://<EC2 Public IP>:3000/
Login with
Username: admin
andPassword: admin
Go to add your first data source
Search and select prometheus
Add URL under the connection
Note: As Grafana and Prometheus are installed in same VM or EC2, i have given localhost:9090 as 9090 port is where prometheus running in our EC2.
And click Save and Test
Go back to Grafana home page and select Create your first Dashboard.
Click on Import a Dashboard
Search for node-exporter id for grafana or go to the link and search the node exporter dashboard and copy the ID https://grafana.com/grafana/dashboards/
Paste the ID and Click on Load
Choose prometheus source and Import
Now finally this is the Dashboard we see