monitor.history

Historical import/export for monitor data.

Pure functions over MetricStore: the JSON --file format and the SQLite database written by live collection. Lenient on read (RowModel), exact on write — the export is byte-compatible with what --file accepts.

otto.monitor.history.load_json_into(store: MetricStore, path: str) None

Load historical metrics and events from a JSON file into store.

Expected format:

{
    "metrics": [{"timestamp": "...", "label": "...", "value": 42.0}, ...],
    "events": [
        {"timestamp": "...", "label": "...", "source": "...", "color": "..."},
        ...,
    ],
}

The host field is optional for backward compatibility.

async otto.monitor.history.load_sqlite_into(store: MetricStore, path: str) None

Load historical metrics and events from a SQLite database into store.

otto.monitor.history.to_json(store: MetricStore) str

Serialize all metrics and events in store to a JSON string compatible with --file.