# Storage, observability, and platform operations

Source: https://cch-plus.com/en/docs/installation/ops-and-storage

> Day-2 operations for self-hosted CCHP deployments—S3 default object storage and migration, request archiving with Langfuse/S3 export, task result storage, internal Prometheus metrics ports, PostgreSQL RLS, live cron scheduling, CPU/PGO profiling, database retention, CC Hub import, and Watchtower auto-updates.

After initial installation, platform super admins handle lifecycle storage governance and day-2 operations from **Administration** → **System Management**—under **Advanced Settings** (consolidating the **Feature flags**, **Observability**, **Usage view**, **Task results**, and **Performance** sub-tabs (since v1.0.16)), **Database**, and **About**—as well as **Administration** → **Cron Jobs**.

## Default object storage and S3 migration (since v1.0.15)

Artifacts without a per-organization storage override—plugin bundles, export files, audit archives, encrypted CC Hub imports, console frontend chunks, and user avatars—are stored in the deployment's **default object store**. It defaults to `objectstore/` under the shared data directory. For multi-node high-availability deployments, switch to S3-compatible storage (AWS S3, Cloudflare R2, MinIO, RustFS, etc.) using the same environment variables across `gateway`, `control`, `worker`, and `cron`:

| Environment variable | Default | Description |
| - | - | - |
| `CCH_OBJECTSTORE_BACKEND` | `local` | Set to `s3` to enable an S3-compatible backend |
| `CCH_OBJECTSTORE_S3_ENDPOINT` | Empty (AWS S3) | Custom S3-compatible endpoint URL for self-hosted or third-party storage |
| `CCH_OBJECTSTORE_S3_REGION` / `BUCKET` | Required for `s3` | Storage region (often `us-east-1` when self-hosted) and bucket name |
| `CCH_OBJECTSTORE_S3_PREFIX` | Empty | Key prefix inside the bucket to isolate multiple deployments sharing one bucket |
| `CCH_OBJECTSTORE_S3_ACCESS_KEY_ID` / `SECRET_ACCESS_KEY` | Required for `s3` | Static access credentials (inject via secrets) |
| `CCH_OBJECTSTORE_S3_FORCE_PATH_STYLE` | `false` | Typically set to `true` for self-hosted RustFS, MinIO, and similar servers |
| `CCH_OBJECTSTORE_LOCAL_FALLBACK` | `true` | Whether to fall back to reading local `objectstore/` on S3 miss or transient error |

### Zero-downtime migration (`gateway objectstore copy`)

Migrate from a local volume to S3 without downtime:

1. Configure `CCH_OBJECTSTORE_BACKEND=s3` and `CCH_OBJECTSTORE_S3_*` on every role (keeping `CCH_OBJECTSTORE_LOCAL_FALLBACK=true` and the existing `objectstore/` volume mounted), then roll out.
2. Inside a pod or container that mounts the local volume and has the same S3 variables set, run the copy command (add `--dry-run` first to preview):
   ```bash
   gateway objectstore copy
   ```
   The command copies objects idempotently under the same keys, skips objects that already exist with matching size, and prints a JSON summary. Pass `--prefix orgs/<org-id>/` to copy a single prefix.
3. Re-run until `copied` and `failed` are both `0` and the metric `cchp_storage_objectstore_fallback_reads_total{reason="not_found"}` stops rising. Then roll out with `CCH_OBJECTSTORE_LOCAL_FALLBACK=false` and safely unmount the legacy local volume.

## Request archive, remote destinations, and dead-letter queue

Open **Administration** → **System Management** → **Advanced Settings** → **Observability** (`/admin/advanced?tab=observability`; legacy `/admin/observability` redirects automatically) (since v1.0.16) to manage local and remote request archive destinations, logging and tracing settings, **Unwritten request records**, and live database connection telemetry:

![Observability: remote request archive destinations (S3-compatible storage and Langfuse) and local staging storage](https://cch-plus.com/en/docs/installation/ops-storage-01-observability.webp)

- **S3 and Langfuse export**: The gateway writes full request bodies and every upstream attempt to a local encrypted archive first, then either uploads chunked AES-GCM encrypted bundles (`CCHPRA2`) to S3-compatible storage or pushes OTLP HTTP v4 spans directly to Langfuse (`inline` from the gateway or asynchronously via NATS JetStream and the standalone `archive-exporter`). Historical backfill is supported for up to 31 days.
- **Unwritten request records (dead-letter queue)** (since v1.0.12): Request billing facts awaiting database persistence are staged in encrypted local files under `usage-journal/` (since v1.0.7). Records that fail persistence enter the **Unwritten request records** section on this page (deep-linked from alerts at `/admin/observability?section=usage-dead-letters`) for root-cause inspection and one-click replay.
- **Database runtime status**: The bottom of the page shows live connection pool utilization, server connections, and slow-statement summaries to pinpoint database bottlenecks quickly.

## Task result storage (since v1.0.1)

Open **Administration** → **System Management** → **Advanced Settings** → **Task results** (`/admin/advanced?tab=task-results`; legacy `/admin/task-results` redirects automatically) (since v1.0.16) to configure where async image, audio, video, and 3D generation outputs are stored:

![Task result storage: active storage backend, disk usage and file counts, and write failure logs](https://cch-plus.com/en/docs/installation/ops-storage-02-task-results.webp)

- **Single active backend with graceful draining**: Only one backend is active at a time (local `task-results/` volume or S3-compatible storage). When you switch backends, the previous storage enters the **Disabled** state, continues serving downloads for existing files, and is removed automatically once all retained files expire.
- **Capacity and write-failure tracking**: Tracks file counts, storage footprint, and write failures per backend so you can scale capacity or catch permission issues early.

## Internal metrics ports and PostgreSQL RLS

- **Internal Prometheus metrics ports** (since v1.0.4): `/metrics` is served exclusively on each role's internal ops port—never on public traffic ports—to keep internal telemetry private:
  - `gateway`: `:8084` (signed internal peer port `:8091`)
  - `control`: `:8085` (internal peer port `:8092`)
  - `worker`: `:8082` (internal peer port `:8093`; `cron` internal peer port `:8094`)
- **PostgreSQL Row-Level Security (RLS)** (since v1.0.7): Every business root table enables both `ENABLE` and `FORCE ROW LEVEL SECURITY`. Long-running services connect as the restricted `cchp_runtime` role (`NOSUPERUSER`, `NOBYPASSRLS`), while owner credentials (`ATLAS_DATABASE_URL`) are held only by the one-shot `migrate` container, enforcing tenant isolation at the database layer.

## Cron jobs and live rescheduling (since v1.0.11)

Open **Administration** → **Cron Jobs** (`/admin/cron`) to monitor and control all built-in system and background scheduled jobs (including `storage_retention`, `storage_pressure_check`, `request_archive_retention`, `task_result_retention`, `upstream_probe`, `pricing_catalog_sync`, `usage_report`, ledger reconciliation `ledger_reconcile` (since v1.0.15), release update checks `release_update_check` (since v1.0.16), and New API group sync `new_api_group_sync` / `new_api_group_sync_dispatch` (since v1.0.16)):

![Cron Jobs: Total jobs, Enabled, and Failed in 24h KPIs, filters, and job list](https://cch-plus.com/en/docs/installation/ops-storage-03-cron.webp)

- **KPI summary and filtering**: Displays live **Total jobs**, **Enabled**, and **Failed in 24h** counters, with filters by job type and last run status (succeeded / failed / partial / canceled).
- **Toggle, run now, and live schedule editing** (since v1.0.11): Every row provides an inline enable toggle and a **Run now** button (without shifting the regular schedule). Expand any row to inspect run history and duration, or click **Edit schedule** to update its Cron expression live without restarting services. Scheduler timeout and concurrency settings sit at the bottom of the page.

## Runtime profiling and scheduled CPU / PGO capture (since v1.0.15)

Open **Administration** → **System Management** → **Advanced Settings** → **Performance** (`/admin/advanced?tab=performance`; legacy `/admin/performance` redirects automatically; visible only with platform-level `profiling:read` / `profiling:run` permissions) (since v1.0.16) to profile live processes from the control plane over master-key-signed internal peer ports—no container exec or unauthenticated `pprof` exposure needed:

![Performance: live process selector, runtime overview, profile capture, and capture history](https://cch-plus.com/en/docs/installation/ops-storage-04-performance.webp)

- **On-demand captures and flame graphs**: Pick any live node (`gateway`, `control`, `worker`) and capture `cpu`, `heap`, `goroutine`, `goroutineleak` (dedicated leak detector), or `trace` profiles. View interactive flame graphs, top functions, side-by-side diffs between two captures, or download `.pb.gz` files directly in the console.
- **Scheduled CPU profiling and PGO merging** (since v1.0.15): By default, the control plane staggers `60`-second (`profiling.schedule.seconds`) 100 Hz CPU captures across live gateway nodes every `6` hours (`profiling.schedule.interval_hours`) and keeps them for `7` days. Operators can fetch a merged `default.pgo` for Profile-Guided Optimization builds via `GET /api/admin/profiling/pgo?role=gateway&days=7`.
- **Automatic heap-threshold capture**: When gateway heap usage exceeds `CCH_HEAP_PROFILE_THRESHOLD` (defaults to `55%` of `GOMEMLIMIT`), the gateway writes a heap profile to its local `heap-profiles/` directory (at most once every 30 minutes, keeping up to 4 files) for post-mortem analysis of memory spikes.
- **Field Web Vitals and performance budgets**: Also reports browser Web Vitals (LCP/INP/CLS p75) alongside configurable request-pipeline latency, memory allocation, and error budget thresholds.

## Database storage retention and automatic shrinking (since v1.0.11)

Open **Administration** → **System Management** → **Database** (`/admin/database`) to configure per-table retention days, shrink floors, and volume free-space thresholds:

![Database: scheduled cleanup toggle, per-category retention days, shrink floors, and safe free-space thresholds](https://cch-plus.com/en/docs/installation/ops-storage-05-database-retention.webp)

- **Tiered cleanup protection**: Cleanable operational data (replay tasks `1` day, settlement messages `1` day, audit streams `7` days, Responses conversation nodes `30` days, per-call charge lines `90` days, request logs `90` days—dropped as whole partitions or chunks) cleans up daily and shrinks one day at a time down to its **Shrink floor** (default `30` days for request logs) under disk pressure. Ledgers (`ledger_*`), wallets, settlements, and audit logs are **protected data** and are never shrunk under pressure.
- **Dual-threshold automatic protection**: The daily `04:45 UTC` job (`storage_retention`) checks whether free volume space fell below the safe threshold (default `20%`), and the hourly `:05` check (`storage_pressure_check`) checks the alert threshold (default `10%`), triggering automatic shrinking immediately. If space remains tight after every cleanable table hits its floor, CCHP fires a **Storage failure** platform alert.

## Import from CC Hub (since v1.0.3)

To migrate organizations, users, keys, providers, and usage data from a legacy Claude Code Hub (CC Hub) deployment, first enable **Database import/export** (`feature.database_import_export`) in [Feature flags](https://cch-plus.com/en/docs/operations/feature-flags). The **Import from CC Hub** card then appears at the bottom of **Database**:

![Import from CC Hub: select target organization, upload an export archive, or pull directly from a running deployment](https://cch-plus.com/en/docs/installation/ops-storage-06-cchub-import.webp)

- **Two import sources**: Upload an exported `.dump`, `.json`, `.zip`, or `.tar.gz` archive from CC Hub, or enter the legacy CC Hub URL and credentials to pull `/api/admin/database/export` directly, review the preflight preview, and launch the background import job.
- **First sign-in with legacy API keys**: After import finishes, existing CC Hub users can claim their migrated account and sign in directly on the login page using their previous API key.

## Auto-updates, official release notes feed, and version alerts (since v1.0.16)

- **Watchtower auto-updates (Docker Compose)** (since v1.0.9): Single-host Compose deployments can layer `compose.watchtower.yml` to run the maintained `nickfedor/watchtower` image, which pulls new images and restarts containers in the required order—stopping the old `cchp`, recreating and running the one-shot `migrate` container (with migration locks and schema verification), and then starting the new `cchp`. Do not use generic updaters without `--include-stopped`, or the exited `migrate` container will not re-run and the new `cchp` will stay at `/readyz` `503`.
- **About page and official release notes API** (since v1.0.16): Under **Administration** → **System Management** → **About** (`/admin/about`), the control plane fetches localized release notes and collapsible historical changelogs matching your UI language from **Official release notes URL** (`updates.release_notes_url`, defaulting to `https://cch-plus.com/release-notes/v1/releases.json`, and falling back to GitHub Releases when left empty)—available even when you are already on the latest version, with an external link to the full release notes on the website.
- **Background update checks and dual-channel alerts** (since v1.0.16): With **Background update checks** (`updates.check_enabled`, on by default) enabled, the `release_update_check` cron job checks the release feed every 6 hours. When a newer semantic version is found, CCHP sends a cross-organization in-app update notice to active system administrators (linking from the top-bar notification bell straight to **About**) and triggers one **Program update available** (`program_update`) platform alert per version to external notification channels and admin email. See [Notifications and daily usage reports](https://cch-plus.com/en/docs/operations/notifications#categories).

![About page: current version, official release notes feed, and localized historical changelog](https://cch-plus.com/en/docs/installation/ops-storage-07-about-updates.webp)

## Frequently asked questions

### Why doesn't the "Import from CC Hub" card appear under Database?

CC Hub import is gated by the `feature.database_import_export` feature flag and is off by default on fresh installs. Enable it under **Administration** → **System Management** → **Advanced Settings** → **Feature flags**, wait up to 5 seconds, and refresh. You can turn the flag off again once migration finishes; any job already running will complete normally.

### Why didn't disk space drop immediately after I lowered database retention days?

`storage_retention` runs daily at `04:45 UTC` by default; to run it immediately, find `storage_retention` in **Administration** → **Cron Jobs** and click **Run now**. Also note that for non-partitioned tables, PostgreSQL reuses freed tuples for future writes rather than returning space immediately to the OS filesystem.

## Related pages

- [Installation overview](https://cch-plus.com/en/docs/installation)
- [Install with Docker Compose](https://cch-plus.com/en/docs/installation/docker-compose)
- [Install on k3s / k8s](https://cch-plus.com/en/docs/installation/kubernetes)
- [Feature flags](https://cch-plus.com/en/docs/operations/feature-flags)
