From 5534bee742acdd3710d203a658c3ad1e9dd42f0f Mon Sep 17 00:00:00 2001 From: Kibue~Ian <108528166+GacheruIan@users.noreply.github.com> Date: Tue, 24 Feb 2026 09:20:42 +0300 Subject: [PATCH 1/3] Add Prometheus installation guide for Linux This guide provides a comprehensive step-by-step process for installing and configuring Prometheus on a Linux system, including creating a service user, setting up directories, and managing the service with systemd. --- prometheus-setup.md | 160 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 prometheus-setup.md diff --git a/prometheus-setup.md b/prometheus-setup.md new file mode 100644 index 0000000..127c3db --- /dev/null +++ b/prometheus-setup.md @@ -0,0 +1,160 @@ +# Prometheus Installation on Linux + +This guide documents the step-by-step installation and configuration of Prometheus using a binary installation approach and running it as a systemd service. + +Prometheus is an open-source monitoring and alerting toolkit used to collect and store time-series metrics in DevOps and cloud environments. + +--- + +## 1. Update System Packages + +```bash +sudo apt-get update +``` + +Purpose + +Refreshes package lists + +Prevents dependency conflicts during installation + +--- + +## 2. Download Prometheus + +```bash +sudo wget https://github.com/prometheus/prometheus/releases/download/v3.10.0-rc.1/prometheus-3.10.0-rc.1.linux-amd64.tar.gz +``` + +Purpose + +Downloads the Prometheus precompiled binary + +## 3. Create Prometheus Service User (Security Best Practice) + +```bash +sudo groupadd --system prometheus +sudo useradd -s /sbin/nologin --system -g prometheus prometheus +``` + +Why + +Prevents Prometheus from running as root + +Improves system security + +## 4. Create Prometheus Directories + +```bash +sudo mkdir /var/lib/prometheus +sudo mkdir -p /etc/prometheus/rules +sudo mkdir -p /etc/prometheus/rules.s +sudo mkdir -p /etc/prometheus/files_sd +``` + +| Directory | Purpose | +| --------------------- | ---------------------------- | +| `/var/lib/prometheus` | Metrics storage (TSDB) | +| `/etc/prometheus` | Configuration files | +| `rules/` | Alerting & recording rules | +| `files_sd/` | File-based service discovery | + + +## 5. Extract Archive + +```bash +sudo tar xzf prometheus-3.10.0-rc.1.linux-amd64.tar.gz +``` +## 6. Move Binaries to System Path + +```bash +sudo mv prometheus promtool /usr/local/bin +prometheus --version +``` + +Why + +Allows Prometheus to run globally + +promtool is used for config validation + + + +## 7. Move Configuration File + +```bash +sudo mv prometheus.yml /etc/prometheus/prometheus.yml +``` + +## 8. Create Systemd Service + +```bash +sudo tee /etc/systemd/system/prometheus.service< Date: Tue, 24 Feb 2026 13:10:27 +0300 Subject: [PATCH 2/3] Add installation guide for Prometheus Node Exporter This guide provides step-by-step instructions for installing and configuring Prometheus Node Exporter as a systemd service on Linux, including downloading, extracting, and setting up the service. --- node_exporter | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 node_exporter diff --git a/node_exporter b/node_exporter new file mode 100644 index 0000000..cf173e4 --- /dev/null +++ b/node_exporter @@ -0,0 +1,189 @@ +# Node Exporter Installation (Linux) + +This guide explains how to install and configure Prometheus Node Exporter as a systemd service. + +Node Exporter exposes Linux system metrics such as CPU, memory, disk, and network statistics so that Prometheus can scrape and store them. + +Default metrics endpoint: +http://SERVER_IP:9100/metrics + +--- + +## 1. Download Node Exporter + +```bash +sudo wget +``` +Purpose + +Downloads the Node Exporter binary from GitHub releases. + +## 2. Extract Archive + +```bash +sudo tar xzf node_exporter-*.tar.gz +``` + +Purpose + +Extracts the Node Exporter binary from the compressed archive. + +## 3. Test Node Exporter Manually + +```bash +./node_exporter +``` + +Result + +Starts Node Exporter + +Exposes metrics on port 9100 + +Verify: + +```bash +http://SERVER_IP:9100/metrics +``` + +This step confirms the binary works before creating a service. + +## 4. Create Prometheus Service User (Security Best Practice) + +```bash +sudo groupadd --system prometheus +sudo useradd -s /sbin/nologin --system -g prometheus prometheus +``` + +Why + +Prevents running exporter as root + +Improves production security + +## 5. Create Installation Directory + +```bash +sudo mkdir /var/lib/node +``` + + +Purpose + +Stores Node Exporter binary in a dedicated location. + +## 6. Move Binary + +```bash +sudo mv node_exporter /var/lib/node/ +``` +##7. Create Systemd Service + +```bash +sudo nano /etc/systemd/system/node.service +``` + +```bash +[Unit] +Description=Prometheus Node Exporter +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=/var/lib/node/node_exporter + +SyslogIdentifier=prometheus_node_exporter +Restart=always + +[Install] +WantedBy=multi-user.target +``` + +Purpose + +Runs Node Exporter as a background service + +Enables restart on failure + +Allows automatic startup during boot + + +## 8. Set Permissions + +```bash +sudo chown -R prometheus:prometheus /var/lib/node +sudo chmod -R 775 /var/lib/node/ +``` + +Why + +Prevents permission-related service failures + +Allows Prometheus user to execute exporter + +## 9. Start and Enable Service + +```bash +sudo systemctl daemon-reload +sudo systemctl start node +sudo systemctl enable node +``` + +## 10. Verify Service + +```bash +sudo systemctl status node +``` + +Then open: + +```bash +http://SERVER_IP:9100/metrics +``` + +What Node Exporter Provides + +CPU usage + +Memory usage + +Disk utilization + +Network statistics + +Filesystem metrics + +Load average + +## Connect Node Exporter to Prometheus + +Add this to prometheus.yml: + +```bash +scrape_configs: + - job_name: "node_exporter" + static_configs: + - targets: ["SERVER_IP:9100"] +``` + +Then restart Prometheus: + +```bash +sudo systemctl restart prometheus +``` + + +⚠️ Common Mistakes + +Forgetting to open firewall port 9100 + +Wrong binary path in systemd service + +Permission denied errors + +Not reloading systemd daemon From c44f39439802e5315d544cec098ce2198e88b1f4 Mon Sep 17 00:00:00 2001 From: Kibue~Ian <108528166+GacheruIan@users.noreply.github.com> Date: Tue, 24 Feb 2026 13:11:07 +0300 Subject: [PATCH 3/3] Rename node_exporter to node_exporter.md --- node_exporter => node_exporter.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename node_exporter => node_exporter.md (100%) diff --git a/node_exporter b/node_exporter.md similarity index 100% rename from node_exporter rename to node_exporter.md