Grafana Prometheus Docker install

Aus xinux.net
Zur Navigation springen Zur Suche springen

Ordner Struktur erstellen

  • mkdir grafana
  • cd grafana
  • mkdir -p data/prometheus grafana-lib prometheus

docker-compose.yml

version: "3"
networks:
  monitor-net:
      driver: bridge
services:
  grafana:
    image: grafana/grafana
    ports:
      - 3000:3000
    volumes:
       - "./grafana-lib:/var/lib/grafana"
     # - "./grafana-etc:/etc/grafana"
    environment:
      - GF_INSTALL_PLUGINS=grafana-clock-panel, michaeldmoore-multistat-panel, briangann-datatable-panel, grafana-worldmap-panel, grafana-piechart-panel
    user: "472"
    networks:
      - monitor-net
  prometheus:
    image: prom/prometheus
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      - ./data/prometheus:/prometheus
    ports:
      - 9090:9090
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
      - '--web.enable-admin-api'
    networks:
      - monitor-net

prometheus.yml

  • vi prometheus/prometheus.yml
# my global config
global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.
  evaluation_interval: 15s # By default, scrape targets every 15 seconds.
  # scrape_timeout is set to the global default (10s).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 'my-ext'

# Load and evaluate rules in this file every 'evaluation_interval' seconds.
rule_files:
  - 'alert.rules'
  # - "first.rules"
  # - "second.rules"

# alert
alerting:
#  alertmanagers:
#  - scheme: http
#    static_configs:
#    - targets:
#      - "alertmanager:9093"

scrape_configs:
- job_name: kali
  static_configs:
  - targets: ['xxx.xxx.xxx.xxx:xxxx']

Bei targets einen Rechner, auf dem ein node-exporter läuft angeben.

docker container starten

  • docker-compose up -d

Login

Passwörter ändern

Linux node-exporter

  • apt install prometheus-node-exporter
  • systemctl enable prometheus-node-exporter --now

Grafana

Datenquelle hinzufügen

Grafana-prometheus-1.png

Grafana-prometheus-2.png

Template hinzufügen

Grafana-prometheus-3.png

Grafana-prometheus-4.png

Grafana-prometheus-5.png

Windows Node Exporter

Download und Installation

Anlegen in Prometheus

- job_name: win10
  static_configs:
  - targets: ['10.10.10.11:9182']

Restart des Containers

  • docker-compose down ; docker-compose up -d

Import des Grafana Templates

https://grafana.com/grafana/dashboards/2129
oder

Import angepasstes Dashboard

In der Webgui:

  • "+" Symbol drücken
    • Import
      • Import JSON file