Files
cheat-sheets/Apps/Node exporter.md
2022-11-01 23:44:04 +01:00

1.7 KiB

Node exporter

Node exporter is a compnantent used by prometheus to get server matrics.

Local installation

Download the script from github: wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz

Extract the tar file: tar xzf node_exporter-1.3.1.linux-amd64.tar.gz

Move file to command folder: sudo mv -v node_exporter-1.1.2.linux-amd64/node_exporter /usr/local/bin/

Set correct persmission in command file: sudo chown root:root /usr/local/bin/node_exporter

Test the command: node_exporter --version

Create a systemd service: sudo nano /etc/systemd/system/node-exporter.service

File shall containe this information:

[Unit]
Description=Prometheus exporter for machine metrics

[Service]
Restart=always
User=root
ExecStart=/usr/local/bin/node_exporter
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no

[Install]
WantedBy=multi-user.target`

Reload the services: sudo systemctl daemon-reload

Start and active the service: Start: sudo systemctl start node-exporter.service Activate: sudo systemctl enable node-exporter.service

Docker installation

version: '3.3'
services:
    node-exporter:
        network_mode: host
        pid: host
        volumes:
            - '/:/host:ro,rslave'
        image: 'quay.io/prometheus/node-exporter:latest'
        
    prometheus:
        container_name: prometheus
        ports:
            - '9090:9090'
        volumes:
            - '/srv/dev-disk-by-uuid-82a4b0b6-2dc5-47df-b93f-d8e213f2f641/config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml'
        image: prom/prometheus:latest