grafana
grafana
&
Beginner Friendly Guide
Table of Contents
1. What is Monitoring
2. What is Prometheus
3. What is Grafana
4. Why Use Prometheus + Grafana
5. How Prometheus Works
6. How Grafana Works
7. What is Node Exporter
8. How Node Exporter Works
9. Installing Prometheus on EC2
10. Configuring Prometheus
11. Alertmanager Overview
12. Installing Grafana on EC2
13. Adding Prometheus as a Data Source
14. What is a Dashboard
15. Creating Dashboards in Grafana.
Priti Bhosale
2
What is Monitoring?
Monitoring is the continuous process of collecting, analyzing, and visualizing system
and application metrics to understand the performance, availability, and overall
health of your infrastructure.
What is Prometheus?
Prometheus is a free and open-source tool used to monitor computers, servers,
applications, and cloud systems. It helps you collect and store data about how your
system is working like CPU usage, memory, disk space, and more and shows you
that data in a way that's easy to understand.
Prometheus is like a smart assistant that keeps checking how your systems are
doing and tells you when something needs your attention.
What is Grafana ?
Grafana is a free and open-source tool used to create beautiful dashboards and
visualize monitoring data collected from tools like Prometheus. Instead of looking at
raw numbers, Grafana helps you see graphs, charts, and alerts which makes it
easier to understand what’s happening in your system.
Grafana is like a dashboard in a car it shows you everything about your system in
one place, in a way that's easy to see and understand.
Prometheus collects data like CPU usage, memory, disk space, and more.
In short Prometheus watches your system. Grafana shows you what’s happening
clearly and beautifully. Together, they make system monitoring easy and smart.
3. Prometheus stores this data with the time it was collected (this is called "time-
series data").
4. You can see or analyze this data using its own web page or by connecting it to a
tool like Grafana for beautiful dashboards.
3
3. You can use Grafana to create dashboards and display that data in graphs
4. You can also set alerts, so Grafana notifies you if something is wrong.
CPU usage
Memory usage
Disk space
Network traffic
System uptime
Prometheus then pulls this data from Node Exporter and stores it for analysis or
alerting.
3. You can visualize the data in Grafana as graphs, gauges, and charts.
- ------------------------------------------------------
sudo tee /etc/yum.repos.d/prometheus.repo <<EOF
[prometheus]
name=Prometheus
baseurl=https://packagecloud.io/prometheus-rpm/release/el/7/x86_64
repo_gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey
https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-
KEY-prometheus-rpm
gpgcheck=1
metadata_expire=300
EOF
-----------------------------------------------------------------
Then:
- sudo yum update -y
- sudo yum -y install prometheus2 node_exporter
5
3. add port 9090 for Prometheus and port 9100 for Node Exporter in security group
3. copy ec2 public IP and paste in browser with port no 9090 now you should see
Prometheus dashboard.
To see Node Exporter copy ec2 public IP and paste in browser with port no 9100
6
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
3. Restart Prometheus
#Detailed setup of Alertmanager is out of scope for this document, but can be explored when
implementing advanced alerting.
Then:
sudo yum install grafana -y
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
8
After Installation:
1. add port 3000 in security group of EC2 (Grafana runs on port no 3000).
2. copy ec2 public IP and paste in browser with port no 3000 now you should see
Grafana dashboard
Elasticsearch
CloudWatch
10
Once a data source is connected, Grafana can fetch data, visualize it, and build
dashboards in real time
What is a Dashboard?
Once Prometheus is connected: Go to the “+” icon on the left click “Dashboard” →
then “Add new panel”. Choose Prometheus as the data source
Graph
Gauge
Table
Pie Chart, etc.
a. node_cpu_seconds_total
b. node_memory_MemAvailable_bytes
13