Black Friday: 50% off every workbook with code . Ends Nov 30, 23:59 ET. Buy Now

Last day: 50% off every workbook ends tonight at 23:59 ET. Code Buy Now

Skip to main content
intermediate Free with email

Prometheus and Grafana: How They Work and How to Set Them Up

Reviewed 2026-11-19

Direct answer
Prometheus collects and stores metrics from your servers, and Grafana turns them into dashboards and alerts. Run Node Exporter on port 9100, point Prometheus (port 9090) at it, then add Prometheus to Grafana (port 3000) as a data source. This free PDF walks through the setup on an EC2 instance.

Prometheus collects and stores metrics from your servers. Grafana turns those metrics into dashboards and alerts. Run Node Exporter on each Linux server, point Prometheus at it on port 9100, then add Prometheus to Grafana as a data source and build a dashboard.

Updated 2026-11-19. Versions checked that day: Prometheus 3.16.0 (LTS 3.13.5) and Node Exporter 1.13.0.

What Are Prometheus and Grafana?

Prometheus is an open-source monitoring and alerting toolkit that collects metrics from servers and applications and stores them as time series data. Grafana is an open-source visualisation tool that reads that data and draws it as graphs, gauges and tables on a dashboard. Prometheus gathers and stores the numbers. Grafana makes them easy to read.

What Is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit, originally built at SoundCloud and started in 2012, according to the Prometheus overview. It joined the Cloud Native Computing Foundation in 2016, and all its components are available under the Apache 2 License.

It works on a pull model. Prometheus requests metrics over HTTP from each target, stores every sample locally with a timestamp, and lets you query the data with PromQL, its query language. It isn’t the right tool when you need 100% accuracy, such as per-request billing. For server health, it fits well.

What Is Grafana?

Grafana OSS is the free, self-managed open source edition of Grafana. It lets you query, visualise, alert on and explore metrics, logs and traces wherever they’re stored, according to the Grafana documentation.

Grafana doesn’t store metric data itself. It connects to outside systems called data sources, such as Prometheus, MySQL or PostgreSQL, Elasticsearch and Amazon CloudWatch. That’s why a Prometheus and Grafana pair works so well: one stores, the other shows.

Go deeper

Practice on real network labs.

The CCNA Lab Workbook has 75 hands-on labs in EVE-NG and Packet Tracer, including SNMP, DHCP, DNS and NTP on a multi-VLAN topology.

See the CCNA Lab Workbook →

Prometheus vs Grafana: What Is the Difference?

Prometheus collects, stores and queries metrics. Grafana displays data from Prometheus and other sources. They aren’t rivals. Most monitoring setups run both, and Grafana can’t draw a Prometheus graph until Prometheus has something stored.

Two-column comparison. Prometheus scrapes metrics and queries them with PromQL. Grafana shows dashboards, connects to data sources and stores no data.
Prometheus vs Grafana: one collects and queries metrics, the other shows dashboards from any data source.
PrometheusGrafana
Main jobCollect, store and query metricsShow data on dashboards and send alerts
How data arrivesPulls from each target’s /metrics pageQueries a data source
Stores metricsYes, in its own time series databaseNo
Query languagePromQLThe language of the data source
AlertsAlerting rules, sent to AlertmanagerGrafana’s own alerting
Default port90903000

Can Grafana work without Prometheus? Yes. Grafana reads from many data sources, and Prometheus is only one of them. Can Prometheus work without Grafana? Yes. It has its own web page for queries and graphs, but Grafana makes dashboards far easier to build and share.

How Prometheus Collects Data From Your Servers

Prometheus collects data by scraping. On a schedule, it requests a /metrics page over HTTP from each target and stores what it finds. An exporter is a small program that exposes a system’s numbers on that page. The sample configuration in the Prometheus getting-started guide scrapes every 15 seconds.

The flow has four steps:

  1. Prometheus asks an exporter for data, such as the current CPU use.
  2. The exporter answers with numbers, such as CPU 30% and memory 40%.
  3. Prometheus stores each number with the time it was collected. That’s time series data.
  4. You read the data on Prometheus’s own web page or through Grafana.

What Is Node Exporter and What Does It Expose?

Node Exporter is the Prometheus exporter for hardware and OS metrics on *NIX kernels such as Linux. It’s built from modular collectors, listens on HTTP port 9100 by default, and shows its metrics at /metrics, according to the Node Exporter project. The cpu and meminfo collectors are on by default.

You install it on every server you want to watch. It covers CPU use, memory, disk space, network traffic and uptime. On Windows, the project recommends the separate Windows exporter instead.

Three metric names you’ll meet first, from the Prometheus Node Exporter guide:

  • node_cpu_seconds_total for CPU time
  • node_filesystem_avail_bytes for disk space available to non-root users
  • node_network_receive_bytes_total for network traffic received

Prometheus, Node Exporter and Grafana Default Ports

Prometheus listens on port 9090, Node Exporter on port 9100 and Grafana on port 3000 by default. All three speak HTTP, so you can check each one in a browser or with curl.

ServiceDefault portWhat you seeWho connects
Grafana3000Login page, then dashboardsYou, in a browser
Prometheus9090Status page and query boxYou, and Grafana
Node Exporter9100A /metrics page of plain textPrometheus

In this guide, Prometheus and Node Exporter share one server. Prometheus scrapes localhost:9100, so port 9100 doesn’t need an inbound rule on the instance at all.

Diagram of three ports on one EC2 server: you open Grafana on 3000 and Prometheus on 9090, and Prometheus scrapes Node Exporter on 9100.
Three ports, one server. Grafana runs on 3000, Prometheus on 9090 and Node Exporter on 9100. Only 3000 and 9090 need to be reachable from your laptop.

How to Install Prometheus and Node Exporter on an EC2 Instance

Download each tarball from GitHub, extract it, start Node Exporter, then start Prometheus with the --config.file flag. That takes a handful of commands and no package manager. Prometheus’s download page lists Prometheus 3.16.0, released 2026-11-04, and Node Exporter 1.13.0, released 2026-11-19.

Three numbered steps with commands: start Node Exporter, start Prometheus with the config file flag, then install Grafana with dnf.
The start order for the stack: Node Exporter first, then Prometheus with prometheus.yml, then Grafana from its RPM repository.

The commands below assume an x86_64 Linux instance such as Amazon Linux 2023. On a Graviton (arm64) instance, download the linux-arm64 file instead of linux-amd64.

Launch the Instance and Set the Security Group

Launch a Linux EC2 instance and connect over SSH. In the security group, allow port 22 from your own IP. Add port 3000 for Grafana and port 9090 for Prometheus, and set the source to My IP, not Anywhere. A source of 0.0.0.0/0 opens the port to the whole internet, and AWS shows a warning for it in the console. Port 9100 stays closed because Prometheus reaches it on localhost.

Install and Start Node Exporter

wget https://github.com/prometheus/node_exporter/releases/download/v1.13.0/node_exporter-1.13.0.linux-amd64.tar.gz
tar xvfz node_exporter-1.13.0.linux-amd64.tar.gz
cd node_exporter-1.13.0.linux-amd64
./node_exporter

Open a second SSH session and check that it answers:

curl http://localhost:9100/metrics | grep "node_"

A long list of lines starting with node_ means Node Exporter works.

Install Prometheus

wget https://github.com/prometheus/prometheus/releases/download/v3.16.0/prometheus-3.16.0.linux-amd64.tar.gz
tar xvf prometheus-3.16.0.linux-amd64.tar.gz
cd prometheus-3.16.0.linux-amd64

Don’t start it yet. Edit the config file first, in the next section.

These commands run in the foreground, so they stop when you close the terminal. The free PDF shows the package route with systemctl start and systemctl status, which keeps the services running after you log out.

How to Configure Prometheus to Scrape Node Exporter

You tell Prometheus where to look in the scrape_configs section of prometheus.yml. Add one job named node with the target localhost:9100, then start Prometheus. The job_name labels the exporter, and targets is the address and port where it runs.

Replace the contents of prometheus.yml with the layout from the Prometheus Node Exporter guide. YAML cares about spaces, so copy the indentation exactly:

global:
  scrape_interval: 15s

scrape_configs:
- job_name: node
  static_configs:
  - targets: ['localhost:9100']

Start Prometheus from its folder:

./prometheus --config.file=./prometheus.yml

The job name matters later. The community dashboard in the dashboard section expects the default job name node, so use that name here.

Confirm the Target Is UP on the Targets Page

Open http://<your-server-public-ip>:9090/targets, or choose Status, then Target health, in the Prometheus menu. Under the node job you should see state UP. That means Prometheus is scraping Node Exporter.

Then click the Graph tab, type node_cpu_seconds_total, and click Execute. You’ll see live data.

What Is Alertmanager and Do You Need It?

Alertmanager is the Prometheus component that handles alerts. Prometheus evaluates alerting rules and sends firing alerts to Alertmanager, which manages them, including silencing, inhibition and aggregation, and sends notifications by email, on-call tools or chat, according to the Prometheus alerting overview.

You don’t need it to draw dashboards. You need it when you want to be told about a problem instead of finding it yourself. This guide stops before Alertmanager setup, because that deserves its own walk-through. Grafana also has its own alerting, which reads from the same data source.

How to Install Grafana on the Same Server

Add Grafana’s RPM repository, install the grafana package with dnf, then start the grafana-server service. Grafana listens on port 3000 by default. The repository address is https://rpm.grafana.com, as given in the Grafana install guide for RHEL and Fedora.

sudo tee /etc/yum.repos.d/grafana.repo <<'EOF'
[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
EOF

sudo dnf install grafana
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl enable grafana-server.service

Each option sits on its own line. A repo file with two options on one line fails.

Open http://<your-server-public-ip>:3000 in a browser. You should see the Grafana sign-in page.

Grafana Default Username and Password

Grafana’s default login is admin for both the username and the password. After you sign in, Grafana prompts you to change the password. The Grafana sign-in guide says it strongly recommends changing it, so do that on first login.

How to Add Prometheus as a Grafana Data Source

In Grafana, open Connections, click Add new connection, search for Prometheus, click Add new data source, enter the Prometheus server URL http://localhost:9090, and click Save & test. Grafana then shows “Successfully queried the Prometheus API.” That’s the message in the Grafana Prometheus data source guide.

Three steps in Grafana: add a new connection, enter http://localhost:9090 as the server URL, then click Save and test.
Add Prometheus as a Grafana data source: Connections, Prometheus, server URL http://localhost:9090, then Save and test.

If Prometheus runs on a different server, use http://<Prometheus-IP>:9090 instead of localhost. Leave the other settings at their defaults. Menu names have moved between Grafana versions. The steps here follow the current Grafana documentation, and the PDF’s screenshots show Grafana 10.4.

How to Build Your First Grafana Dashboard for Server Monitoring

Create a new dashboard, add a visualisation, choose the Prometheus data source, type a PromQL query and run it. A graph with live data appears. Start with CPU and memory, the two panels the free PDF builds. Then pick a visualisation type such as time series, gauge, table or pie chart, set the unit, and save the dashboard with a name.

PromQL for CPU and Memory Usage

CPU time in Node Exporter is a counter. Prometheus defines a counter as a cumulative metric that can only increase or be reset to zero on restart. If you graph node_cpu_seconds_total raw, you get a line that only climbs. Wrap it in rate(), which the Prometheus docs describe as the per-second average rate of increase of a series over a range, and use it only on counters.

PanelQueryWhat it shows
CPU busy (%)100 - (avg(rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)Share of CPU time not idle, averaged over 5 minutes
CPU in system moderate(node_cpu_seconds_total{mode="system"}[1m])Seconds of system-mode CPU per second
Memory available (%)node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100Share of RAM still available
Network inrate(node_network_receive_bytes_total[1m])Bytes received per second
Disk freenode_filesystem_avail_bytesBytes available to non-root users

Memory is a gauge, so you query it directly. A gauge is a value that can go up and down. Set the unit to Percent (0-100) for the percentage panels and bytes for the others. Without a unit, Grafana shows a bare number such as 597680128, which is hard to read.

Import a Ready-Made Node Exporter Dashboard

Node Exporter Full is a community dashboard on grafana.com with ID 1860. It only requires the default job name node, which is why the configuration step above uses it. In Grafana, open Dashboards, choose New, then Import, enter 1860, and pick your Prometheus data source. You get dozens of CPU, memory, disk and network panels without writing a query.

Self-Hosted on EC2 or Amazon Managed Prometheus and Grafana?

Self-hosting on EC2 means you install, patch and scale Prometheus and Grafana yourself. Amazon Managed Service for Prometheus and Amazon Managed Grafana are AWS-run services that remove that work and bill by usage. For one or two servers and a learning setup, the self-hosted route in this guide is the simpler start.

OptionWho runs itFacts from the vendor docs
Self-hosted on EC2YouYou choose versions, storage and backups
Amazon Managed Service for PrometheusAWSServerless and Prometheus-compatible. Uses PromQL. Keeps data 150 days by default, up to 1095 days. Replicates data across three Availability Zones. Billed for ingestion and storage of metrics
Amazon Managed GrafanaAWSAWS manages provisioning, setup, scaling and maintenance. Priced per active user in a workspace. Works with Amazon Managed Service for Prometheus as a data source
Grafana CloudGrafana LabsManaged platform with a free tier of up to three users and 10k metrics

AWS describes its Prometheus service as built for container metrics, and it works with Amazon EKS and self-managed Kubernetes clusters. Sources: Amazon Managed Service for Prometheus, Amazon Managed Grafana and the Grafana OSS page.

Prometheus and Grafana Security Checklist

A monitoring server exposes details about your machines, so lock it down before you leave it running. Four checks cover most of the risk:

  1. Limit the ports. Allow 3000 and 9090 only from your own IP, or from a VPN or reverse proxy you control.
  2. Keep 9100 closed. Node Exporter exposes a wide variety of hardware and kernel metrics. When Prometheus runs on the same server, it reaches Node Exporter on localhost.
  3. Change the Grafana password. Replace the default admin password on first login.
  4. Check the rules after changes. Every new service you add tempts you to open one more port. Review the security group each time.

What to Learn Next

You now have a working stack: Node Exporter, Prometheus and Grafana. These are the next steps, in a sensible order:

What Is Inside the Free Prometheus and Grafana PDF?

Frequently asked questions

What are Prometheus and Grafana?
Prometheus is an open-source monitoring and alerting toolkit that collects metrics from servers and stores them as time series data. Grafana is an open-source tool that turns data from sources such as Prometheus into dashboards and alerts. Prometheus gathers and stores the numbers, and Grafana makes them easy to read. Most teams run them together.
Is Prometheus the same as Grafana?
No. Prometheus collects, stores and queries metrics with its own query language, PromQL, and listens on port 9090. Grafana stores no metrics itself. It connects to data sources such as Prometheus and draws dashboards from them, and it listens on port 3000. Prometheus is the data layer, and Grafana is the display layer.
Do you need Prometheus to use Grafana?
No. Grafana connects to many data sources, and Prometheus is only one of them. The free PDF lists Prometheus, MySQL and PostgreSQL, Elasticsearch and Amazon CloudWatch as examples. You need Prometheus only when you want to collect and store server metrics yourself, which is what Node Exporter and Prometheus do together.
What port does Prometheus use?
Prometheus listens on port 9090 by default. Node Exporter, which exposes server metrics for Prometheus to scrape, listens on port 9100, and Grafana listens on port 3000. All three use HTTP. When Prometheus and Node Exporter run on the same server, port 9100 doesn't need an inbound rule because Prometheus scrapes localhost:9100.
What is the default Grafana username and password?
The default Grafana login is admin for the username and admin for the password. After you sign in, Grafana prompts you to change the password. Grafana's documentation strongly recommends changing it, so do it on first login, especially on a server that other people can reach over the network.
Is Grafana free and open source?
Yes. Grafana's documentation states that Grafana is open source and free to use, and that you can download Grafana OSS and self-host it at no cost. Grafana Enterprise adds commercial features such as enterprise data source plugins. Grafana Cloud is a managed service from Grafana Labs, and it has a free tier.
What is Node Exporter used for?
Node Exporter is the Prometheus exporter for hardware and operating system metrics on Linux and other *NIX systems. It runs on each server you want to watch, exposes CPU, memory, disk and network numbers at /metrics on port 9100, and lets Prometheus scrape them. For Windows servers, the Prometheus project recommends the separate Windows exporter.
How does Prometheus collect data?
Prometheus uses a pull model. On a schedule, it requests a /metrics page over HTTP from each target, such as Node Exporter, and stores every value as a sample with a timestamp. The sample configuration in its getting-started guide scrapes every 15 seconds. You then query the stored data with PromQL or view it in Grafana.
What is Alertmanager and do I need it?
Alertmanager is the Prometheus component that handles alerts. Prometheus evaluates alerting rules and sends firing alerts to Alertmanager, which manages them, including silencing, inhibition and aggregation, and sends notifications by email, on-call tools or chat. You don't need it to draw dashboards. You need it when you want a message about a problem.
Is Prometheus still used?
Yes. Prometheus is actively maintained: version 3.16.0 was released on 2026-11-04, and its download page also lists a long-term support release, 3.13.5. The project joined the Cloud Native Computing Foundation in 2016, and its overview says many companies and organizations have adopted it since 2012.

Questions about this PDF

No questions yet. Ask the first one.

Ask a question

Your email address won't be published. We review every question before it appears. How we handle your data. Required fields are marked

Reviewed by

CCDE/CCIE

How to cite this resource

SMEnode Labs (2026). Prometheus and Grafana: How They Work and How to Set Them Up. SMEnode Labs. https://smenode-labs.com/free-pdf/devops/prometheus-grafana/

APA

SMEnode Labs. (2026). Prometheus and Grafana: How They Work and How to Set Them Up. SMEnode Labs. https://smenode-labs.com/free-pdf/devops/prometheus-grafana/

BibTeX

@misc{smenodelabs2026,
  title = {Prometheus and Grafana: How They Work and How to Set Them Up},
  author = {{SMEnode Labs}},
  year = {2026},
  url = {https://smenode-labs.com/free-pdf/devops/prometheus-grafana/},
  note = {SMEnode Labs}
}