Files
memory/systems/influxdb.md
T
2026-11-20 22:00:22 +00:00

78 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "InfluxDB — drei Instanzen, zwei Aufgaben (hot / Archiv / tote K8s-Kopie)"
category: systems
tags: [influxdb, homeassistant, historie, archive, flux, k8s]
created: "2026-11-20"
modified: "2026-11-20"
---
# InfluxDB
> **Kurzfassung:** HA schreibt auf `.109` (90 Tage). Ein stündlicher Flux-Task dort schreibt das ablaufende Tagesfenster als 5-Minuten-Mittel nach `.110` (5 Jahre). Eine dritte Instanz in K8s (`.204`) ist **leer** und hat 18 tote Tasks — eine begonnene, nie verdrahtete Migration.
## Die drei Instanzen
| Rolle | Adresse | Wo | Version | Bucket / Retention | Zustand 20.11.2026 |
|---|---|---|---|---|---|
| **Hot** | `10.0.30.109:8086` | LXC **109** `influxdb` auf proxmox6 | v2.7.11 | `ha_hot_90d`, 90 d | **schreibend**; ältester Punkt 22.08.2026; ~1.817 Entities in 30 d |
| **Archiv** | `10.0.30.110:8086` | LXC **134** `influxdb-archive` auf proxmox6 | v2.7.11 | `ha_archive_5y_5m`, 5 Jahre | **seit 23.08.2026 gerissen**: Bestand 06.05.–23.08., **78 Tage fehlen** (24.08.–20.11.) |
| **K8s** | `10.0.30.204:8086` | NS `influxdb`, Pod `influxdb-0`, LB | v2.7.12 | `ha_hot_90d` + `ha_archive_5y_5m` | **leer** (Engine 1,1 MB); 18 identische Tasks, die den lokalen leeren Hot-Bucket lesen; tägliche Backup-CronJobs |
Org überall `homelab` — aber **unterschiedliche Org- und Token-IDs**. Tokens sind nicht austauschbar.
## Der Datenfluss
```
Home Assistant (VM106)
│ influxdb-Integration (UI-Config-Entry, source: import — NICHT die YAML)
▼
10.0.30.109 : ha_hot_90d (90 Tage, rohe States)
│ Flux-Task "archive_5m_to_hdd_90d", stündlich, offset 10m
│ range(start:-91d, stop:-90d) → aggregateWindow(5m, mean) → to(host: .110)
▼
10.0.30.110 : ha_archive_5y_5m (5 Jahre, 5-Minuten-Mittel)
```
Der Archiv-Token steht **im Flux-Skript** des Tasks (`GET /api/v2/tasks` auf `.109`, Feld `flux`). Er taucht in keiner YAML auf.
## Zwei Fallen
1. **YAML lügt.** `configuration.yaml` enthält weiterhin einen `influxdb:`-Block mit `host: 10.0.30.204`, `token: …`, `bucket: ha_hot_90d`. Seit HA **2026.9** sind die Verbindungs-Keys dort wirkungslos (nur `include`/`exclude`/`tags` bleiben); die Verbindung lebt im UI-Entry (`source: import`) und zeigt auf `.109`. Wer die Datei liest, konfiguriert das Falsche.
2. **Die Archivkette riss am 23.08.2026 — und wurde am 20.11. repariert.** Der stündliche Task lief mit `range(-91d,-90d)`, also genau an der Retention-Kante; dort war bereits gelöscht, `to()` bekam null Zeilen und meldete trotzdem `success`. Hot: 23.08.–20.11. (79 Tage), Archiv: 05.05.–23.08. (91 Tage) → **78 Tage fehlten**.
- **Fix:** Task jetzt `every: 6h`, `range(-2d,-1d)`. Ein 3-Tage-Fenster scheiterte am Remote-Timeout von `to()`; die 6-h-Kadenz gibt 4 idempotente Chancen pro Tag. Verifiziert: Lauf 20.11. 13:00 `success`, 70.472 Punkte im Fenster.
- **Backfill:** `~/.hermes/profiles/hauswacht/workspace/scripts/backfill_archiv.py` — **abgeschlossen**: 79 Tage, 0 Fehler, Archiv 91 → **168 Tage** (05.05.–20.11.), 50 → ~105 MB.
- **Echte Aufzeichnungslücke:** 22.09.–02.10.2026 fehlt **auch in Hot** (11 Tage) — nicht rekonstruierbar. 03.10. hatte nur einen Rest (386 Entities), nachgezogen.
- **Pitfall:** `aggregateWindow` labelt mit dem Fenster-**Ende**; ohne `timeSrc:"_start"` ist jede Tageszählung um eins verschoben (hätte Fehlalarm erzeugt).
- **Wächter:** `watchers/entwurf/archiv_luecke.py` — echter Lauf `NO_REPLY` (jüngster Punkt 0 h, 8 Tage, Task frisch), `--selftest` grün, **nicht scharf** (Schattenlauf).
## Semantik (wichtig für Flux)
- `default_measurement: units` → **Measurement = Einheit** (`"W"`, `"%"`, `"EUR/kWh"`, …).
- Entität ist **Tag** `entity_id` (plus `domain`, `friendly_name`, `source=HA`).
- Numerischer Wert: Feld **`value`**; String-Attribute als `<name>_str`.
- Abfrage also:
```flux
from(bucket:"ha_hot_90d") |> range(start:-24h)
|> filter(fn:(r)=> r.entity_id=="pv_production" and r._field=="value")
```
## Betrieb
```bash
# Health
curl -s http://10.0.30.109:8086/health
curl -s http://10.0.30.110:8086/health
# Tasks (inkl. Flux + Token)
curl -s -H "Authorization: Token $TK" http://10.0.30.109:8086/api/v2/tasks
# Buckets/Retention
curl -s -H "Authorization: Token $TK" "http://10.0.30.109:8086/api/v2/buckets?org=homelab"
```
## Related
- [[systems/homeassistant]] — schreibende Integration, Recorder
- [[systems/hauswacht]] — read-only Analyst, der diese Kette nutzt (V-006)
- Solution: `docs/solutions/bug-fixes/2026-11-20-influxdb-drei-instanzen-yaml-luegt.md`