Monitoring Ec2 Instance
Monitoring Ec2 Instance
Grafana
How Grafana and Prometheus work together
Grafana and Prometheus are probably the most prominent
tools in the application monitoring and analytics
space. Prometheus is an open-source monitoring and alerting
platform that collects and stores metrics as time-series data
Grafana is an open-source analytics and interactive
visualization web application. It allows you to ingest data
from a huge number of data sources, query this data, and
display it on beautiful customizable charts for easy analysis. It
is also possible to, set alerts so you can quickly and easily be
notified of abnormal behavior and lots more.
Agenda:
1. Install Prometheus and configure Prometheus to monitor
itself
2. Install Node Exporter on the other EC2 Instances
3. Configure Prometheus for the EC2 Instance
4. Install Grafana
Requirement:
Launching 3 Amazon linux instances
Pawar Divya
Solution :
• Step 1: Security groups configures on EC2 Instances
Prometheus security group port number 9090 enabled
1. Installing Prometheus
Launch one instance.
$ sudo yum install git
$ cd prometheus-monitoring
$ ./install-prometheus.sh
Pawar Divya
This script will install everything and configured it.
• Creates a new user and add new directories
sudo useradd --no-create-home prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
Pawar Divya
• copy the following content in yml file.
$ cd /etc/systemd/system/
$ vi prometheus.service
Pawar Divya
• Save and exit.
Change the ownership of all folders and files which we have
created to the user which we have created in the first step
sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
sudo chown -R prometheus:prometheus /var/lib/prometheus
http:<node-exporter-public-ip>:9100
Pawar Divya
➢ Step 3: Configure Prometheus for the Nodes
Now we will configure the Prometheus for our EC2 instance
where we have installed the node-exporter.
Login to the Prometheus server and edit the file file at
location in Prometheus instance
/etc/prometheus/prometheus.yml
Now you can open the Prometheus using below url and can
see the new targets added
http://<prometheus-public-ip>:9090/targets
Pawar Divya
➢ Step 4: Install Grafana
Once Prometheus is installed successfully then we can install
the Grafana and configure Prometheus as a datasource.
Grafana is an opensource tool which is used to provide the
visualization of your metrics.
1. Steps to Install:
2. Run the below file for apt-get pckg manager
Pawar Divya
4. Start the service and check the status
Pawar Divya
Add Prometheus DataSource
Click on setting > Data sources
Pawar Divya
Click on Prometheus
Pawar Divya
Scroll down click save and test.
Pawar Divya
You will get dashboards
Pawar Divya
Click on Load
Pawar Divya
Conclusion :
We have come to know how to install Prometheus and
grafana to monitor Ec2 instances
Pawar Divya