From 9707e6631e1a6b03636ac21e59035851d4e4f897 Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Fri, 25 Oct 2024 16:44:28 +0200 Subject: [PATCH] add: prometheus --- prometheus/README.md | 10 ++++ prometheus/node-exporter.md | 105 ++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 prometheus/README.md create mode 100644 prometheus/node-exporter.md diff --git a/prometheus/README.md b/prometheus/README.md new file mode 100644 index 0000000..76ac4cc --- /dev/null +++ b/prometheus/README.md @@ -0,0 +1,10 @@ + +# prometheus + +## install prometheus + +https://www.youtube.com/watch?app=desktop&v=yrscZ-kGc_Y&ab_channel=Techdox + +## install node_exporter + +wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz \ No newline at end of file diff --git a/prometheus/node-exporter.md b/prometheus/node-exporter.md new file mode 100644 index 0000000..5a2b33b --- /dev/null +++ b/prometheus/node-exporter.md @@ -0,0 +1,105 @@ +# Setting Up Node Exporter + +## Download Node Exporter + +Begin by downloading Node Exporter using the wget command: + +```bash +wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz +``` + +Note: Ensure you are using the latest version of Node Exporter and the correct architecture build for your server. The provided link is for amd64. For the latest releases, check here - Prometheus Node Exporter Releases + +## Extract the Contents¶ + +After downloading, extract the contents with the following command: + +```bash +tar xvf node_exporter-1.7.0.linux-amd64.tar.gz +``` + +## Move the Node Exporter Binary¶ + +Change to the directory and move the node_exporter binary to /usr/local/bin: + +```bash +cd node_exporter-1.7.0.linux-amd64 +``` + +```bash +sudo cp node_exporter /usr/local/bin +``` + +Then, clean up by removing the downloaded tar file and its directory: + +```bash +rm -rf ./node_exporter-1.7.0.linux-amd64 +``` + +## Create a Node Exporter User¶ + +Create a dedicated user for running Node Exporter: +```bash +sudo useradd --no-create-home --shell /bin/false node_exporter +``` + +Assign ownership permissions of the node_exporter binary to this user: +```bash +sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter +``` + +## Configure the Service¶ + +To ensure Node Exporter automatically starts on server reboot, configure the systemd service: + +```bash +sudo nano /etc/systemd/system/node_exporter.service +``` + +Then, paste the following configuration: + +```properties +[Unit] +Description=Node Exporter +Wants=network-online.target +After=network-online.target + +[Service] +User=node_exporter +Group=node_exporter +Type=simple +ExecStart=/usr/local/bin/node_exporter +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target +``` + +Save and exit the editor. + +## Enable and Start the Service¶ + +Reload the systemd daemon: + +```bash +sudo systemctl daemon-reload +``` + +Enable the Node Exporter service: +```bash +sudo systemctl enable node_exporter +``` + + +Start the service: + +```bash +sudo systemctl start node_exporter +``` + +To confirm the service is running properly, check its status: + +```bash +sudo systemctl status node_exporter.service +```