commit 00fb7f51d7c92a353c59fa629a80a40d62789155 Author: sorb Date: Thu Jul 30 12:12:11 2026 +0200 monitoring: Bestandsaufnahme des laufenden Stacks Import des bisherigen Stands aus /opt/monitoring auf dem Operating-Host, unveraendert. Images auf :latest, Grafana ohne Provisioning (Datasources und Dashboards nur in der grafana.db), keine Dokumentation. Dient als Ausgangspunkt fuer den Umbau auf einen vollstaendig provisionierbaren Stack. Co-Authored-By: Claude Opus 5 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/monitoring/alloy/config.alloy b/monitoring/alloy/config.alloy new file mode 100644 index 0000000..6f28404 --- /dev/null +++ b/monitoring/alloy/config.alloy @@ -0,0 +1,26 @@ +discovery.docker "linux_containers" { + host = "unix:///var/run/docker.sock" +} + +loki.source.docker "docker_logs" { + host = "unix:///var/run/docker.sock" // Diesen Wert habe ich hinzugefügt + targets = discovery.docker.linux_containers.targets + forward_to = [loki.write.local_loki.receiver] +} + +loki.write "local_loki" { + endpoint { + url = "http://loki:3100/loki/api/v1/push" + } +} + +prometheus.scrape "node_exporter" { + targets = [{"__address__" = "node-exporter:9100"}] + forward_to = [prometheus.remote_write.local_prometheus.receiver] +} + +prometheus.remote_write "local_prometheus" { + endpoint { + url = "http://prometheus:9090/api/v1/write" + } +} diff --git a/monitoring/docker-compose.yml b/monitoring/docker-compose.yml new file mode 100644 index 0000000..6330bbc --- /dev/null +++ b/monitoring/docker-compose.yml @@ -0,0 +1,100 @@ +services: + prometheus: + image: prom/prometheus:latest + container_name: prometheus + restart: unless-stopped + volumes: + - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro + - prometheus_data:/prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + - '--storage.tsdb.path=/prometheus' + - '--storage.tsdb.retention.time=45d' + - '--storage.tsdb.retention.size=15GB' + - '--web.enable-remote-write-receiver' + ports: + - "9090:9090" + networks: + - traefik + + loki: + image: grafana/loki:latest + container_name: loki + restart: unless-stopped + volumes: + - ./loki/loki-config.yaml:/etc/loki/local-config.yaml:ro + - loki_data:/loki + command: -config.file=/etc/loki/local-config.yaml + ports: + - "3100:3100" + networks: + - traefik + + alloy: + image: grafana/alloy:latest + container_name: alloy + restart: unless-stopped + volumes: + - ./alloy/config.alloy:/etc/alloy/config.alloy:ro + - /var/log:/var/log:ro + - /var/lib/docker/containers:/var/lib/docker/containers:ro + - /var/run/docker.sock:/var/run/docker.sock:ro + command: run --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy + cap_add: + - DAC_READ_SEARCH + - NET_RAW + networks: + - traefik + depends_on: + - prometheus + - loki + + grafana: + image: grafana/grafana:latest + container_name: grafana + restart: unless-stopped + environment: + - GF_SECURITY_ADMIN_USER=${Grafana_ADMIN} + - GF_SECURITY_ADMIN_PASSWORD=${Grafana_ADMIN_PW} + volumes: + - grafana_data:/var/lib/grafana + labels: + - "traefik.enable=true" + - "traefik.docker.network=traefik" + - "traefik.http.routers.grafana.rule=Host(`selendis.axion1337.de`)" + - "traefik.http.routers.grafana.entrypoints=websecure" + - "traefik.http.routers.grafana.tls.certresolver=le" + - "traefik.http.services.grafana.loadbalancer.server.port=3000" + depends_on: + - prometheus + - loki + networks: + - traefik + + node-exporter: + image: prom/node-exporter:latest + container_name: 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' + - '--web.listen-address=:9100' + - '--web.disable-exporter-metrics' + ports: + - "9100:9100" + networks: + - traefik + +volumes: + prometheus_data: + grafana_data: + loki_data: + +networks: + traefik: + external: true diff --git a/monitoring/loki/loki-config.yaml b/monitoring/loki/loki-config.yaml new file mode 100644 index 0000000..2103ac6 --- /dev/null +++ b/monitoring/loki/loki-config.yaml @@ -0,0 +1,37 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + +common: + instance_addr: 127.0.0.1 + path_prefix: /loki + storage: + filesystem: + chunks_directory: /loki/chunks + rules_directory: /loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +limits_config: + retention_period: 2160h + # Hier war der Fehler: + allow_structured_metadata: true + +schema_config: + configs: + - from: 2024-01-01 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +# Der chunk_store_config Block wurde entfernt, da 'common' das jetzt übernimmt. + +table_manager: + retention_deletes_enabled: true + retention_period: 2160h diff --git a/monitoring/prometheus/prometheus.yml b/monitoring/prometheus/prometheus.yml new file mode 100644 index 0000000..864da66 --- /dev/null +++ b/monitoring/prometheus/prometheus.yml @@ -0,0 +1,42 @@ +global: + scrape_interval: 15s + +# local metrics +scrape_configs: + ## operating server + - job_name: "operating_prometheus" + static_configs: + - targets: ["localhost:9090"] + + - job_name: "operating_node-exporter" + static_configs: + - targets: ["node-exporter:9100"] + + - job_name: "operating_cadvisor" + static_configs: + - targets: ["cadvisor:8080"] + + - job_name: "operating_traefik" + metrics_path: "/metrics" + static_configs: + - targets: ["traefik:8080"] + + - job_name: "k3s_host_node" + static_configs: + - targets: ["10.0.0.2:9100"] + labels: + instance: "k3s-host" + + - job_name: "pterodactyl_host_node" + static_configs: + - targets: ["157.90.155.206:9100"] + labels: + instance: "pterodactyl" + + - job_name: "gameserver_cadvisor" + static_configs: + - targets: ["157.90.155.206:8080"] + ## matrix server (auskommentiert, aber jetzt syntaktisch korrekt eingerückt) + # - job_name: "matrix_prometheus" + # static_configs: + # - targets: ["matrix-server-ip:9090"]