Hier zeige ich euch, wie ihr in ein paar Minuten ein cooles Dashboard bekommt, welches euch diverse Sachen über euren Server anzeigt. Traefik dient uns hier als Reverse Proxy und stellt später den Dienst verschlüsselt per TLS bereit.

Update

03.01.2020 Bilder erneuert.
27.04.2020 Traefik „secHeaders“ hinzugefügt. Dashboard erweitert.
14.04.2020 Erstellung dieser Anleitung.

Wer Traefik noch nicht installiert hat, findet hier eine Anleitung, wie ihr dies schnell tun könnt.

Als Grundlage meiner Anleitung dient dient diese Anleitung. Ich habe diese jedoch etwas erweitert und an Traefik angepasst.

So kann später dann euer Dashboard aussehen:

Dazu werden wir gleich folgende Tools installieren

  • Prometheus
  • node-exporter
  • cadvisor
  • grafana

1. Ordner anlegen

Zuerst legen wir uns passende Ordner-Strukturen an.

mkdir -p /opt/containers/grafana/{grafana,prometheus}

Nun ändern wir noch die Berechtigungen.

chown 1000:1000 /opt/containers/grafana/grafana

2. Docker Compose anlegen

Hier legen wir die Docker Compose an.

cd /opt/containers/grafana/
nano docker-compose.yml
---
version: '3'

services:
  mon_prometheus:
    image: prom/prometheus:latest
    container_name: mon_prometheus
    restart: unless-stopped
    volumes:
      - $PWD/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
    depends_on:
      - mon_node-exporter
      - mon_cadvisor
    networks:
      - default

  mon_node-exporter:
    image: prom/node-exporter:latest
    container_name: mon_node-exporter
    restart: unless-stopped
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--path.rootfs=/rootfs'
      - '--collector.filesystem.ignored-mount-points="^(/rootfs|/host|)/(sys|proc|dev|host|etc)($$|/)"'
      - '--collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue)(fs|)$$"'
    networks:
      - default

  mon_cadvisor:
    image: google/cadvisor:latest
    container_name: mon_cadvisor
    restart: unless-stopped
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    networks:
      - default

  mon_grafana:
    image: grafana/grafana:latest
    container_name: mon_grafana
    restart: unless-stopped
    volumes:
      - /opt/containers/grafana/grafana:/var/lib/grafana
    user: "1000" # USER ID des Docker Users anpassen
    depends_on:
      - mon_prometheus
    networks:
      - default

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.entrypoints=http"
      - "traefik.http.routers.grafana.rule=Host(`grafana.euredomain.de`)"  ## Hier eure Domain eingeben ##
      - "traefik.http.middlewares.grafana-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.grafana.middlewares=grafana-https-redirect"
      - "traefik.http.routers.grafana-secure.entrypoints=https"
      - "traefik.http.routers.grafana-secure.rule=Host(`grafana.euredomain.de`)" ## Hier eure Domain eingeben ##
      - "traefik.http.routers.grafana-secure.tls=true"
      - "traefik.http.routers.grafana-secure.tls.certresolver=http"
      - "traefik.http.routers.grafana-secure.service=grafana"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.grafana-secure.middlewares=secHeaders@file"

    networks:
      - proxy
      - default

networks:
  proxy:
    external: true

Notwendige Anpassungen:

  1. 2x eure URL eingeben bei Traefik

3. prometheus.yml anlegen

Nun legen wir noch eine Konfigurationsdatei für Prometheus an.

nano /opt/containers/grafana/prometheus/prometheus.yml
global:
  scrape_interval: 15s
  evaluation_interval: 15s
rule_files:
scrape_configs:
  - job_name: 'node-exporter'
    static_configs:
      - targets: ['mon_node-exporter:9100']

  - job_name: 'cadvisor'
    static_configs:
      - targets: ['mon_cadvisor:8080']

4. Grafana starten

Wie gewohnt starten wir nun Grafana mittels folgendem Befehl:

docker-compose -f /opt/containers/grafana/docker-compose.yml up -d

5. Grafana Konfigurieren

5.1 Einloggen

Nun geht ihr auf „grafana.euredomain.de“ und solltet folgendes sehen:

Die Zugangsdaten lauten:

  • Name: admin
  • Passwort: admin

Wenn ihr euch einloggt, werdet ihr aufgefordert das Kennwort zu ändern.

Nun solltet ihr folgendes sehen.

5.2 Mit Prometheus Datenbank verbinden

Nun klickt ihr auf „Add data source“.

Hier wählt ihr „Prometheus“ aus.

Hier gebt ihr nun unter „URL“ folgendes ein:

http://mon_prometheus:9090

Nun scrollt ihr nach unten und klickt auf „Save & Test“. Wenn alles ok ist, dann sollte es bei euch so aussehen.

5.3 Dashboard hinzufügen

Ihr könnt euch nun ein Dashboard selbst zusammenbauen oder eins kostenlos von der Grafana Community beziehen.

Wenn ihr mein Dashboard haben wollt, so müsst ihr folgendes tun.

Klickt auf das „+“ links oben und wählt „Import“ aus.

Hier kopiert ihr nun folgenden Code in das Feld. Ihr könnt den Code komplett markieren und dann kopieren.

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "",
  "editable": true,
  "gnetId": 893,
  "graphTooltip": 1,
  "id": 1,
  "iteration": 1588003866954,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "rgba(245, 54, 54, 0.9)",
        "rgba(237, 129, 40, 0.89)",
        "rgba(50, 172, 45, 0.97)"
      ],
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "format": "none",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 0
      },
      "id": 31,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "count(rate(container_last_seen{name=~\".+\"}[$interval]))",
          "format": "time_series",
          "intervalFactor": 2,
          "refId": "A",
          "step": 1800
        }
      ],
      "thresholds": "",
      "title": "Containers",
      "type": "singlestat",
      "valueFontSize": "120%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "datasource": null,
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 4,
        "y": 0
      },
      "id": 35,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "last"
          ],
          "defaults": {
            "mappings": [],
            "max": 100,
            "min": 0,
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            },
            "title": ""
          },
          "overrides": [],
          "values": false
        },
        "orientation": "auto",
        "showThresholdLabels": false,
        "showThresholdMarkers": false
      },
      "pluginVersion": "6.7.2",
      "targets": [
        {
          "expr": "100 - (avg by (cpu) (irate(node_cpu_seconds_total{mode=\"idle\"}[1m])) *100)",
          "hide": false,
          "interval": "",
          "legendFormat": "",
          "refId": "A"
        },
        {
          "expr": "(irate(node_cpu_seconds_total{mode=\"idle\"}[1m])) ",
          "hide": true,
          "interval": "",
          "legendFormat": "",
          "refId": "B"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "CPU Auslastung",
      "type": "gauge"
    },
    {
      "cacheTimeout": null,
      "datasource": "Prometheus",
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 13,
        "y": 0
      },
      "id": 25,
      "links": [],
      "options": {
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "defaults": {
            "decimals": 0,
            "mappings": [
              {
                "id": 0,
                "op": "=",
                "text": "N/A",
                "type": 1,
                "value": "null"
              }
            ],
            "max": 100,
            "min": 0,
            "nullValueMode": "connected",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "rgba(50, 172, 45, 0.97)",
                  "value": null
                },
                {
                  "color": "rgba(237, 129, 40, 0.89)",
                  "value": 70
                },
                {
                  "color": "rgba(245, 54, 54, 0.9)",
                  "value": 90
                }
              ]
            },
            "unit": "percent"
          },
          "overrides": [],
          "values": false
        },
        "orientation": "horizontal",
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "pluginVersion": "6.7.2",
      "targets": [
        {
          "expr": "((node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes) * 100  ",
          "format": "time_series",
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "",
          "refId": "A",
          "step": 1800
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "RAM Auslastung",
      "type": "gauge"
    },
    {
      "datasource": null,
      "gridPos": {
        "h": 6,
        "w": 7,
        "x": 17,
        "y": 0
      },
      "id": 39,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            },
            "unit": "decbytes"
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto"
      },
      "pluginVersion": "6.7.2",
      "targets": [
        {
          "expr": "node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes",
          "interval": "",
          "legendFormat": "",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "RAM Verbrauch",
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "rgba(50, 172, 45, 0.97)",
        "rgba(237, 129, 40, 0.89)",
        "rgba(245, 54, 54, 0.9)"
      ],
      "datasource": "Prometheus",
      "decimals": 0,
      "editable": true,
      "error": false,
      "format": "decbytes",
      "gauge": {
        "maxValue": 500000000,
        "minValue": 0,
        "show": true,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 4
      },
      "id": 30,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "(node_memory_SwapTotal_bytes{instance=~'mon_node-exporter:9100'} - node_memory_SwapFree_bytes{instance=~'mon_node-exporter:9100'})",
          "format": "time_series",
          "intervalFactor": 2,
          "legendFormat": "",
          "refId": "A",
          "step": 1800
        }
      ],
      "thresholds": "400000000",
      "title": "Swap",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorValue": false,
      "colors": [
        "rgba(50, 172, 45, 0.97)",
        "rgba(237, 129, 40, 0.89)",
        "rgba(245, 54, 54, 0.9)"
      ],
      "datasource": "Prometheus",
      "decimals": 1,
      "editable": true,
      "error": false,
      "format": "percentunit",
      "gauge": {
        "maxValue": 1,
        "minValue": 0,
        "show": true,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 5,
        "w": 4,
        "x": 13,
        "y": 6
      },
      "id": 26,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "min((node_filesystem_size_bytes{fstype=~\"xfs|ext4\",instance=\"mon_node-exporter:9100\"} - node_filesystem_free_bytes{fstype=~\"xfs|ext4\",instance=\"mon_node-exporter:9100\"} )/ node_filesystem_size_bytes{fstype=~\"xfs|ext4\",instance=\"mon_node-exporter:9100\"})",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "",
          "refId": "A",
          "step": 1800
        }
      ],
      "thresholds": "0.75, 0.90",
      "title": "Festplatten Auslastung",
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "datasource": "Prometheus",
      "gridPos": {
        "h": 5,
        "w": 7,
        "x": 17,
        "y": 6
      },
      "id": 13,
      "links": [],
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            },
            "unit": "decbytes"
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto"
      },
      "pluginVersion": "6.7.2",
      "targets": [
        {
          "expr": "node_filesystem_size_bytes{fstype=\"ext4\"} - node_filesystem_free_bytes{fstype=\"ext4\"}",
          "format": "time_series",
          "hide": false,
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "{{device}}",
          "refId": "A",
          "step": 600
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Festplatten Verbrauch",
      "type": "stat"
    },
    {
      "aliasColors": {
        "IN on /sda": "#7EB26D",
        "OUT on /sda": "#890F02"
      },
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {},
      "gridPos": {
        "h": 9,
        "w": 9,
        "x": 4,
        "y": 7
      },
      "hiddenSeries": false,
      "id": 3,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "-sum(rate(node_disk_read_bytes_total[$interval])) by (device)",
          "format": "time_series",
          "hide": false,
          "intervalFactor": 2,
          "legendFormat": "OUT on /{{device}}",
          "metric": "node_disk_bytes_read",
          "refId": "A",
          "step": 600
        },
        {
          "expr": "sum(rate(node_disk_written_bytes_total[$interval])) by (device)",
          "format": "time_series",
          "intervalFactor": 2,
          "legendFormat": "IN on /{{device}}",
          "metric": "",
          "refId": "B",
          "step": 600
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Disk I/O",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": false,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {
        "SENT": "#BF1B00"
      },
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {},
      "gridPos": {
        "h": 8,
        "w": 4,
        "x": 0,
        "y": 8
      },
      "hiddenSeries": false,
      "id": 19,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 1,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rate(container_network_receive_bytes_total{id=\"/\"}[$interval])) by (id)",
          "intervalFactor": 2,
          "legendFormat": "RECEIVED",
          "refId": "A",
          "step": 600
        },
        {
          "expr": "- sum(rate(container_network_transmit_bytes_total{id=\"/\"}[$interval])) by (id)",
          "hide": false,
          "intervalFactor": 2,
          "legendFormat": "SENT",
          "refId": "B",
          "step": 600
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Netzwerk Verkehr",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": false,
        "values": []
      },
      "yaxes": [
        {
          "format": "bytes",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 11,
        "x": 13,
        "y": 11
      },
      "hiddenSeries": false,
      "id": 9,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rate(container_network_transmit_bytes_total{name=~\".+\"}[$interval])) by (name)",
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "A",
          "step": 240
        },
        {
          "expr": "rate(container_network_transmit_bytes_total{id=\"/\"}[$interval])",
          "hide": true,
          "intervalFactor": 2,
          "legendFormat": "",
          "refId": "B",
          "step": 10
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Sent Network Traffic per Container",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": "",
          "logBase": 10,
          "max": 8,
          "min": 0,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "fill": 5,
      "fillGradient": 0,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 13,
        "x": 0,
        "y": 16
      },
      "hiddenSeries": false,
      "id": 1,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pluginVersion": "6.7.2",
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rate(container_cpu_usage_seconds_total{name=~\".+\"}[$interval])) by (name) * 100",
          "hide": false,
          "interval": "",
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "metric": "",
          "refId": "F",
          "step": 240
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "CPU Usage per Container",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "percent",
          "label": "",
          "logBase": 1,
          "max": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "fill": 1,
      "fillGradient": 0,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 11,
        "x": 13,
        "y": 18
      },
      "hiddenSeries": false,
      "id": 8,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rate(container_network_receive_bytes_total{name=~\".+\"}[$interval])) by (name)",
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "A",
          "step": 240
        },
        {
          "expr": "- rate(container_network_transmit_bytes_total{name=~\".+\"}[$interval])",
          "hide": true,
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "B",
          "step": 10
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Received Network Traffic per Container",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "cumulative"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "Bps",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "Prometheus",
      "editable": true,
      "error": false,
      "fill": 3,
      "fillGradient": 0,
      "grid": {},
      "gridPos": {
        "h": 7,
        "w": 13,
        "x": 0,
        "y": 23
      },
      "hiddenSeries": false,
      "id": 10,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 2,
      "links": [],
      "nullPointMode": "null as zero",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(container_memory_rss{name=~\".+\"}) by (name)",
          "hide": false,
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "A",
          "step": 240
        },
        {
          "expr": "container_memory_usage_bytes{name=~\".+\"}",
          "hide": true,
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "B",
          "step": 240
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Memory Usage per Container",
      "tooltip": {
        "msResolution": true,
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "bytes",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "columns": [
        {
          "text": "Current",
          "value": "current"
        }
      ],
      "datasource": null,
      "editable": true,
      "error": false,
      "fontSize": "100%",
      "gridPos": {
        "h": 8,
        "w": 11,
        "x": 13,
        "y": 25
      },
      "id": 37,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 1,
        "desc": true
      },
      "styles": [
        {
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [
            "10000000",
            " 25000000"
          ],
          "type": "number",
          "unit": "decbytes"
        }
      ],
      "targets": [
        {
          "expr": "sum(container_spec_memory_limit_bytes{name=~\".+\"} - container_memory_usage_bytes{name=~\".+\"}) by (name) ",
          "hide": true,
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "metric": "",
          "refId": "A",
          "step": 240
        },
        {
          "expr": "sum(container_spec_memory_limit_bytes{name=~\".+\"}) by (name) ",
          "hide": true,
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "B",
          "step": 240
        },
        {
          "expr": "container_memory_usage_bytes{name=~\".+\"}",
          "hide": false,
          "intervalFactor": 2,
          "legendFormat": "{{name}}",
          "refId": "C",
          "step": 240
        }
      ],
      "title": "Usage memory",
      "transform": "timeseries_aggregations",
      "type": "table"
    }
  ],
  "refresh": "5s",
  "schemaVersion": 22,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "auto": true,
        "auto_count": 50,
        "auto_min": "50s",
        "current": {
          "selected": false,
          "text": "30s",
          "value": "30s"
        },
        "hide": 0,
        "label": "interval",
        "name": "interval",
        "options": [
          {
            "selected": false,
            "text": "auto",
            "value": "$__auto_interval_interval"
          },
          {
            "selected": true,
            "text": "30s",
            "value": "30s"
          },
          {
            "selected": false,
            "text": "1m",
            "value": "1m"
          },
          {
            "selected": false,
            "text": "2m",
            "value": "2m"
          },
          {
            "selected": false,
            "text": "3m",
            "value": "3m"
          },
          {
            "selected": false,
            "text": "5m",
            "value": "5m"
          },
          {
            "selected": false,
            "text": "7m",
            "value": "7m"
          },
          {
            "selected": false,
            "text": "10m",
            "value": "10m"
          },
          {
            "selected": false,
            "text": "30m",
            "value": "30m"
          },
          {
            "selected": false,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": false,
            "text": "6h",
            "value": "6h"
          },
          {
            "selected": false,
            "text": "12h",
            "value": "12h"
          },
          {
            "selected": false,
            "text": "1d",
            "value": "1d"
          },
          {
            "selected": false,
            "text": "7d",
            "value": "7d"
          },
          {
            "selected": false,
            "text": "14d",
            "value": "14d"
          },
          {
            "selected": false,
            "text": "30d",
            "value": "30d"
          }
        ],
        "query": "30s,1m,2m,3m,5m,7m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
        "refresh": 2,
        "skipUrlSync": false,
        "type": "interval"
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "Docker - System Dashboard",
  "uid": "0E0FhC7Wz",
  "variables": {
    "list": []
  },
  "version": 1
}

Danach klickt ihr auf „Load“.

Nun klickt ihr „Import“.

Jetzt solltet ihr folgendes sehen.

6. Quellen

https://www.robustperception.io/understanding-machine-cpu-usage
https://teqqy.de/docker-monitoring-mit-prometheus-und-grafana/

Teile diesen Beitrag
Christian

Categories:

9 Kommentare

  1. Hallo wie kann ich mir den die Server „Uptime“ ins Dashboard einbauen?
    Hast du zufällig damit schon Kontakt gehabt?

    Grüße

  2. Hast du dir das Thema „Alerts“ mal angeschaut? Macht eigentlich Sinn! Du kannst direkt in deiner Docker-Compose Datei den smtp Host definieren und in grafana „Alerts“ einrichten. Würde mich interessieren ob es bei dir klappt.

  3. Hi Christian!
    Nachdem ich deiner Anleitung gefolgt war, bekam ich auf meinem Dashboard immer wieder eine Fehlermeldung und viele Kacheln waren leer.
    Ich habe nach einiger Zeit herausgefunden, dass in der JSON-File in Zeile 6 bei „datasource“ „Prometheus“ statt “ – Grafana – “ stehen muss, weil die Datasource die vorher erstellt wurde so heißt.
    Vielleicht ein Hinweis, falls jemand das gleiche Problem hat 🙂
    Liebe Grüße
    Jonas

  4. Hallo,

    Danke Christian für die Anleitung und danke Jonas für den Hinweis!
    Leider bekomme ich bei diversen Tabellen die Meldung: ‚N/A‘, ‚No Data‘ oder ‚No data to show‘.
    Bin der oben stehenden Anleitung Step by Step gefolgt, da frag ich mich nun was habe ich falsch gemacht oder was ich noch ändern muss? Hat da jemand von euch ein Hinweis? Wäre cool, danke.

    Grüsse
    Gabriel

  5. Hallo Christian,
    vielen Dank für die sehr gute Anleitung!
    Gibt es eine Möglichkeit auf Grafana ein User zu anlegen, der ohne Anmeldedaten auf die Übersicht (Dashboard) kommt? Das wäre für mich interessant, vielleicht hast du eine Idee wie das funktioniert. Wäre cool, wenn du das mit uns teilst.

    Vielen Grüße
    Koray

  6. Hallo.

    Ich bekomme leider nachdem ich unter URL folgendes eingetragen habe „http://mon_prometheus:9090“ folgende Fehlermeldung: HTTP Error Bad Gateway. Ich hoffe mir kann da vielleicht jemand weiterhelfen.

    Grüße Ted

  7. Hi Christian,

    vielen Lieben dank für die ganzen guten Beschreibungen. Hut ab.

    Ich habe bei mit Docker Rootless laufen kann es sein das Grafana/Prometheus root rechte benötigt.

    Beste Grüße

    Rainer

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.