User Tools

Site Tools


prometheus

This is an old revision of the document!


Prometheus

Grafana

compose.yml

version: "3"
services:
    grafana:
      image: grafana/grafana
      container_name: grafana
      restart: unless-stopped
      ports:
          - "3000:3000"
      volumes:
          - grafana-storage:/var/lib/grafana
volumes:
    grafana-storage: {}

Prometheus

compose.yml

version: "3"
services:
    prometheus:
        image: prom/prometheus
        container_name: prometheus
        command:
            - '--config.file=/etc/prometheus/prometheus.yml'
        ports:
            - 9090:9090
        restart: unless-stopped
        volumes:
            - /home/sebmas/docker/prometheus/etc:/etc/prometheus
            - prom_data:/prometheus
volumes:
    prom_data: {}

prometheus.yml

global:
  scrape_interval: 15s
  scrape_timeout: 10s
  evaluation_interval: 15s
alerting:
  alertmanagers:
  - static_configs:
    - targets: []
    scheme: http
    timeout: 10s
    api_version: v1
scrape_configs:
- job_name: prometheus
  honor_timestamps: true
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - localhost:9090

Node exporter

cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-armv7.tar.gz
tar -zxf node_exporter-1.7.0.linux-armv7.tar.gz
mv node_exporter-1.7.0.linux-armv7/node_exporter /usr/local/bin
useradd --no-create-home --shell /bin/false node_exporter
chown node_exporter:node_exporter /usr/local/bin/node_exporter
mkdir -p /opt/config/etc/systemd/system/
cd /opt/config/etc/systemd/system
nano node_exporter.service
[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

ln -s /opt/config/etc/systemd/system/node_exporter.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable node_exporter
systemctl start node_exporter
systemctl status node_exporter

prometheus 2

at the end of prometheus.yml

- job_name: rpi
  static_configs:
  - targets: ['192.168.1.20:9100']

grafana 2

  1. add data source –> prometheus
  2. create dashboard –> import a dashboard –> https://grafana.com/grafana/dashboards/1860-node-exporter-full –> copy id and give it to grafana
prometheus.1707228869.txt.gz · Last modified: by ssm2017