> For the complete documentation index, see [llms.txt](https://services.validexis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://services.validexis.com/monitoring/node-exporter-+-prometheus-+-grafana.md).

# 📊  Node-exporter + Prometheus + Grafana

In this guide, we’ll set up a monitoring system to collect metrics from all servers and visualize them in Grafana.

We will use a dedicated server to host **Prometheus**, **Grafana**, and **Node Exporter**, while only **Node Exporter** will be installed on other servers.

* **Prometheus** is an open-source time-series database written in Go. It pulls metrics from defined services, eliminating data queue bottlenecks and ensuring reliable monitoring.
* **Node Exporter** exports server metrics in a format compatible with Prometheus. While Prometheus supports many exporters, Node Exporter is ideal for server monitoring.
* **Grafana** is a web-based tool for visualizing time-series data from Prometheus and other databases. Although Prometheus has its own web interface, Grafana is recommended for advanced visualization.

The setup flow is as follows: **Node Exporter** collects server metrics → **Prometheus** stores the data → **Grafana** visualizes it in dashboards.

## *Node Exporter*

#### ***Install and Set Up Node Exporter***

```bash
# Download and extract Node Exporter
cd $HOME && \
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz && \
tar xvf node_exporter-1.8.2.linux-amd64.tar.gz && \
rm node_exporter-1.8.2.linux-amd64.tar.gz && \
sudo mv node_exporter-1.8.2.linux-amd64 node_exporter && \
chmod +x $HOME/node_exporter/node_exporter && \
sudo mv $HOME/node_exporter/node_exporter /usr/local/bin && \
rm -Rvf $HOME/node_exporter/

# Create a system user with restricted permissions for Node Exporter
sudo useradd --no-create-home --shell /bin/false node_exporter
```

#### ***Create and Enable the\*\*\*\* ****`exporterd`**** \*\*\*\*Service***

```bash
# Create the systemd service file
sudo tee /etc/systemd/system/node_exporterd.service > /dev/null <<EOF
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
ExecStart=/usr/local/bin/node_exporter
Restart=always
RestartSec=3
LimitNOFILE=65535

[Install]
WantedBy=default.target
EOF

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable node_exporterd
sudo systemctl restart node_exporterd

sudo systemctl status node_exporterd
```

<figure><img src="/files/nZHwAcgl5Bx42Nvouqxm" alt=""><figcaption></figcaption></figure>

#### ***Verify Logs***

```bash
sudo journalctl -u node_exporterd -f
```

#### ***Access Node Exporter Metrics***

Open a web browser and navigate to:\
\&#xNAN;**`http://<server_IP>:9100/`**

Replace `<server_IP>` with the actual IP address of your server running `node_exporter`.

## *Prometheus*

#### ***Update Repositories and Upgrade Packages***

```bash
sudo apt update && sudo apt upgrade -y
```

#### ***Install Necessary Utilities***

```bash
sudo apt install -y curl iptables build-essential git wget jq make gcc nano tmux htop nvme-cli pkg-config libssl-dev libleveldb-dev tar clang bsdmainutils ncdu unzip python3-pip
pip install yq
```

```bash
# Create a Prometheus User
sudo useradd -m -s /bin/bash prometheus
sudo groupadd --system prometheus
sudo usermod -aG prometheus prometheus
```

#### ***Download and Install Prometheus***

```bash
# Create Necessary Directories
sudo mkdir /var/lib/prometheus
for i in rules rules.d files_sd; do sudo mkdir -p /etc/prometheus/${i}; done
mkdir -p /tmp/prometheus && cd /tmp/prometheus
```

```bash
#Download Prometheus
curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | xargs wget
```

```bash
# Extract and Move Prometheus Binaries
tar xvf prometheus*.tar.gz
cd prometheus*/
sudo mv prometheus promtool /usr/local/bin/
```

```bash
# Check Installed Versions
prometheus --version
promtool --version
```

```bash
# Move Configuration Files
sudo mv prometheus.yml /etc/prometheus/prometheus.yml
sudo mv consoles/ console_libraries/ /etc/prometheus/
```

#### ***Create the Prometheus Service File***

```bash
sudo tee /etc/systemd/system/prometheus.service > /dev/null <<EOF
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP \$MAINPID
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090 \
--web.external-url=

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target
EOF
```

> *You can replace the port `9090` with a custom port if needed (e.g., `8080`).*

#### ***Set Permissions***

```bash
for i in rules rules.d files_sd; do sudo chown -R prometheus:prometheus /etc/prometheus/${i}; done
for i in rules rules.d files_sd; do sudo chmod -R 775 /etc/prometheus/${i}; done
sudo chown -R prometheus:prometheus /var/lib/prometheus/
```

#### ***Start and Enable the Prometheus Service***

```bash
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus
```

<figure><img src="/files/qqvfYnFxZpKpptW78fQh" alt=""><figcaption></figcaption></figure>

#### ***Access Prometheus***

Open a web browser and navigate to:\
\&#xNAN;**`http://<server_IP>:9090/`**\
Replace `<server_IP>` with the IP address of the server running Prometheus.

<figure><img src="/files/wZtYHjkmBzo06saxLH85" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/0EEX5iVT0xVoNJPSdC1r" alt=""><figcaption></figcaption></figure>

#### ***Add Additional Servers to Prometheus Configuration***

To monitor multiple servers, update the `prometheus.yml` configuration file with the relevant settings for each server.

#### ***Open the Prometheus Configuration File***

```bash
sudo nano /etc/prometheus/prometheus.yml
```

#### ***Add a New Job for Monitoring***

Here’s an example configuration for a job named `celestia-consensus` that monitors the target at `localhost:26660`.

<pre class="language-yaml"><code class="lang-yaml"><strong>- job_name: celestia-consensus
</strong>  static_configs:
  - targets: ['localhost:26660']
</code></pre>

<figure><img src="/files/WyMnEe5uOLclDNkrUqo0" alt=""><figcaption></figcaption></figure>

You can replace `localhost:26660` with the IP address and port of the server or service you want to monitor.

For example, if monitoring another server:

```yaml
- job_name: my-second-server
  static_configs:
    - targets: ['192.168.1.100:9100'] 
```

#### ***Restart Prometheus***

Restart the Prometheus service to apply the new configuration:

```bash
sudo systemctl restart prometheus
```

#### ***Verify Prometheus is Running Properly***

Check the service status to ensure Prometheus is running without issues:

```bash
sudo systemctl status prometheus
```

#### ***Access Prometheus***

Navigate to **`http://<server_IP>:9090/targets`** in your web browser to see the list of active targets and ensure that the new job is being monitored.

## *Grafana*

#### ***Install Required Dependencies***

```bash
sudo apt-get install -y apt-transport-https software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
```

#### ***Add the Grafana Repository***

```bash
echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
```

#### ***Create a User for Grafana***

```bash
sudo useradd -m -s /bin/bash grafana
sudo groupadd --system grafana
sudo usermod -aG grafana grafana
```

#### ***Install Grafana Enterprise***

```bash
#Install Additional Utilities
sudo apt-get install -y adduser libfontconfig1
```

```bash
#Download and Install Grafana Enterprise
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_9.3.2_amd64.deb
sudo dpkg -i grafana-enterprise_9.3.2_amd64.deb
```

#### ***Start and Enable the Grafana Server***

```bash
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
sudo systemctl status grafana-server
```

<figure><img src="/files/v9VsnZI7bAjoWDbnWU1f" alt=""><figcaption></figcaption></figure>

#### &#x20;***Access Grafana***

Open a web browser and navigate to:\
\&#xNAN;**`http://<server_IP>:3000`**

Replace `<server_IP>` with your server's IP address.

* Default **username**: `admin`
* Default **password**: `admin` (You will be prompted to change it after the first login).

<figure><img src="/files/2iDjRbICuWBZQRsVurqk" alt=""><figcaption></figcaption></figure>

After changing the password, click "Configuration" and then "Data Sources".

<figure><img src="/files/g3O6tRZGYIdzZWZ8Hbw9" alt=""><figcaption></figcaption></figure>

Now click on Add data source and select the Prometheus data source.

<figure><img src="/files/NUrgpY5CWp5BwQ9JVKYZ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Tx5s1MEXDr2KmEmn6cYi" alt=""><figcaption></figcaption></figure>

#### ***Access Prometheus***

To access Prometheus, enter the **IP address** followed by port **9090** .

* If you are running **Prometheus and Grafana on the same server**, use:\
  \&#xNAN;**`http://localhost:9090`**
* If **Prometheus and Grafana are on separate servers**, enter the **IP address of the Prometheus server**, for example:\
  \&#xNAN;**`http://<Prometheus_IP>:9090`**

Replace `<Prometheus_IP>` with the actual IP address of your Prometheus server.

<figure><img src="/files/5N6lgGMZ3K40cwBmBof3" alt=""><figcaption></figcaption></figure>

Save the settings.

<figure><img src="/files/ESjHcSIkjoGMA44qxDGw" alt=""><figcaption></figcaption></figure>

#### ***Download Grafana Dashboard JSON Files***

To set up dashboards in Grafana, you need the **JSON files** of the dashboards. These files can either be:

1. **Downloaded** from a public source like Grafana's [Dashboard Library](https://grafana.com/grafana/dashboards/).
2. **Shared** by someone else.
3. **Created** by you directly in Grafana.

* If you’re using Grafana's library, search for the dashboard by its **ID** and download the JSON file.
* Once downloaded, you can **import** the JSON file into Grafana through the **Import Dashboard** option in the Grafana interface.

<figure><img src="/files/NIviW4kooZK1WqAfKQz2" alt=""><figcaption></figcaption></figure>

Now click on Import and then on Upload JSON file.

<figure><img src="/files/rwOpanE9SL61Px14P9ND" alt=""><figcaption></figcaption></figure>

Upload the JSON file you downloaded earlier, then select the Prometheus data source you just configured and click the +Import button.

<figure><img src="/files/1OnZMm4PVX21SDxbp09w" alt=""><figcaption></figcaption></figure>

Now you have a fully functional monitoring system that can scale to include additional servers and services as needed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://services.validexis.com/monitoring/node-exporter-+-prometheus-+-grafana.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
