Skip to main content

Operations Runbook

Procedures for operating a Konsolidat stack deployed with deploy.sh. All commands run on the Docker host, in the checkout directory, unless stated otherwise.

Where things run​

ComponentWhereHow to reach it
Frappe web, worker, schedulercontainers konsolidat_backend, konsolidat_worker, konsolidat_schedulerdocker compose exec frappe_backend bench --site konsolidat.local <command>
dbtthe Frappe image's bench venv (/home/frappe/frappe-bench/env/bin/dbt), project bind-mounted at /home/frappe/dbt_projectdocker compose --profile setup run --rm dbt_init
ClickHousecontainer konsolidat_clickhousedocker compose exec clickhouse clickhouse-client --password "$CLICKHOUSE_PASSWORD"
LogsDocker json-file logs, 3 x 100 MB per container; Frappe logs also in the frappe_logs volume at /home/frappe/frappe-bench/logs inside the containersdocker compose logs -f --tail=100 frappe_backend

dbt_project/ in the checkout is bind-mounted into every Frappe container. A dimension published in Desk rewrites the konsol-managed block of dbt_project/dbt_project.yml in your working tree; commit it.

Monthly close​

The close runs in the close app at /close (My work, Trial balances, Checks, Sign-off). Configuration stays in Desk. The operator's part is:

  1. Get the data in. Entities with a connector: start a pipeline run (below). Entities without one: they upload trial balances in /close or through Trial Balance Upload in Desk (Check file, then Load). A submitted trial balance queues a governed build on its own (doc_events in hooks.py).
  2. Build the warehouse. Open Pipeline Run in Desk, click New, then Run Pipeline. Creating a run needs System Manager; the button also checks the EPM Admin role. Or run dbt directly: docker compose --profile setup run --rm dbt_init. Only one run at a time; a second start is refused by the single-flight lock.
  3. Run the checks. An Analyst runs the close assertions in /close (Checks). Each run is an Assertion Run document: total, passed, failed, warned, errored, and the sign-off state. A dbt warn is amber and must be acknowledged; an error blocks sign-off.
  4. Review consolidation. In the consolidated trial balance check: CTA where rates differ, intercompany eliminations net to zero, top-side journals balanced, NCI at the ownership percentages.
  5. Sign off. The Close Lead (EPM Admin) signs off in /close, with a typed acknowledgement for amber and an override reason for red. Close Settings must declare the first close period, self_approval and rate_move_threshold, or sign-off stays blocked.
  6. Refresh Excel. Recalculate (Ctrl+Alt+F9). The K. functions read the latest build.

Critical tests for month end, all in dbt_project/tests/:

  • assert_trial_balance_balances: debits equal credits per entity and period
  • assert_silver_gl_debit_credit_balance: GL-level balance
  • assert_ic_elimination_nets_zero: eliminations net to zero
  • assert_fctb_entity_layer_ties: consolidation ties to the entity layer
  • assert_spread_sums_to_annual: budget spread integrity
  • assert_staging_not_stale: every konsol-owned staging table was reached by the latest reconcile (see Monitoring)

Pipeline runs and schedules​

  • Pipeline (Desk): a named definition with ordered Pipeline Step rows (depends_on, params). The shipped definitions are fixtures.
  • Pipeline Run: one execution. Statuses: Queued, Extracting, Transforming, Running, Completed, Failed, Cancelled. The Steps tab shows each Run Step; the Log tab streams the build log. Fields: skip_sync (no Airbyte extract), full_refresh, fiscal_year, fiscal_period, scope.
  • Pipeline Schedule: a 5-field cron (minute hour dom month dow) that starts a Pipeline. konsol.orchestrator.cron.run_due_schedules runs every minute from the Frappe scheduler.
  • Build Approval: a save of a consolidation input (Consolidation Group, Ownership Period, Group Exchange Rate, Trial Balance Submission, and the others listed in hooks.py) requests a governed build. Pending builds show under Builds waiting on the Konsol workspace; approve from the record's Actions menu.
  • Stuck runs are released by cron: reap_stale_runs and reap_stale_build_approvals every 15 minutes, reap_stale_close_runs (Assertion Runs) every 10 minutes.

If the skip_airbyte_sync box in EPM Settings is set, runs skip the extract phase.

Running dbt by hand​

# full build (what deploy.sh step 5 runs)
docker compose --profile setup run --rm dbt_init

# any other dbt command: override the arguments
docker compose --profile setup run --rm dbt_init run --select gold_trial_balance+ \
--profiles-dir /home/frappe/dbt_project --project-dir /home/frappe/dbt_project
docker compose --profile setup run --rm dbt_init test --select assert_trial_balance_balances \
--profiles-dir /home/frappe/dbt_project --project-dir /home/frappe/dbt_project

Common selections: tag:gold, +<model> (upstream), <model>+ (downstream), --full-refresh. The project has 101 models (30 staging, 16 bronze, 10 silver, 45 gold) and 134 singular tests on 2026-11-05; the exact numbers change with every release, so read dbt build's summary line rather than this page.

Do not run dbt from the host against the live ClickHouse with a different Python: the image's venv is the supported runtime.

Reconcile the warehouse​

konsol writes its reference data (entities, chart, fiscal calendar, rates, consolidation structure, hierarchies) into epm_staging on every document save, and stamps epm_staging.sync_watermark. reconcile_all re-writes every write-through table in full (TRUNCATE and INSERT), so a table whose documents vanished without a save (a migration, a restore, a volume that outlived the site) is repaired.

It runs by itself after bench migrate (so after every ./deploy.sh) and after the configurator sets a new ClickHouse target. Run it by hand after a restore, after any direct edit in ClickHouse, or when assert_staging_not_stale reports LAGGING or EMPTIED:

docker compose exec frappe_backend bench --site konsolidat.local \
execute konsol.clickhouse.reconcile_all
docker compose --profile setup run --rm dbt_init

Every watermark the call stamps carries that run's id (konsolidat#246). A run that fails partway leaves its partial run in the watermark, and the test names every table it did not reach. Reconcile jobs are serialised per database by a Redis lock.

Backup and restore​

Nightly:

0 2 * * * cd /path/to/konsolidat && ./deploy.sh backup >> /var/log/konsolidat-backup.log 2>&1

./deploy.sh backup dumps MariaDB, exports every ClickHouse table in epm, epm_staging, epm_bronze, epm_silver, epm_gold, and tars sites/. It keeps BACKUP_RETENTION_DAYS (7) days and never builds the image; if the image is missing it exits 1 and the log says so.

Restore:

set -a; source .env; set +a
./deploy.sh restore --from ./backups/2026-11-04_0200/
docker compose restart
docker compose exec frappe_backend bench --site konsolidat.local execute konsol.clickhouse.reconcile_all
docker compose --profile setup run --rm dbt_init

Uploaded trial balances live in epm_raw, which the backup does not export. After a restore, their rows are rebuilt by resetting and re-loading the Trial Balance Upload documents (the restore brings the documents; a restored document never submits again). A cross-site restore carries the source site's ClickHouse password in EPM Settings; put this stack's password back before anything else.

A Frappe-only backup from inside the container also works: docker compose exec frappe_backend bench --site konsolidat.local backup --with-files writes to sites/konsolidat.local/private/backups/ in the frappe_sites volume.

ClickHouse maintenance​

-- database sizes
SELECT database, formatReadableSize(sum(bytes_on_disk)) AS size
FROM system.parts WHERE active GROUP BY database ORDER BY sum(bytes_on_disk) DESC;

-- row counts
SELECT database, table, formatReadableQuantity(sum(rows)) AS rows
FROM system.parts WHERE active AND database LIKE 'epm%' GROUP BY database, table ORDER BY database, table;

-- after a large load
OPTIMIZE TABLE epm_gold.gold_trial_balance FINAL;

-- running queries
SELECT query_id, elapsed, query FROM system.processes ORDER BY elapsed DESC;

Check disk on the host as well: docker system df and df -h /var/lib/docker. The Docker log cap (3 x 100 MB per container) is in the compose file; do not remove it.

Frappe maintenance​

docker compose exec frappe_backend bench --site konsolidat.local clear-cache
docker compose restart frappe_backend frappe_worker frappe_scheduler
docker compose logs -f --tail=100 frappe_worker
docker compose exec frappe_backend bench --site konsolidat.local execute \
frappe.core.doctype.scheduled_job_type.scheduled_job_type.sync_jobs

sync_jobs re-registers konsol's cron jobs (connector health, reapers, schedules); the configurator runs it on every deploy.

Desk CSS or JS 404 after an image rebuild: the asset manifest in the frappe_sites volume is stale. Both the configurator and the backend entrypoint run refresh-assets.sh, which restores the baked manifest only when the live one is missing or older (konsolidat#131). Restart frappe_backend to trigger it.

Troubleshooting quick checks​

IssueCheck
API errorsdocker compose logs --tail=200 frappe_backend; Error Log list in Desk
ClickHouse downdocker compose ps; curl -sf http://localhost:8123/ping
konsol.api.health says down or degradedClickHouse unreachable, or a write-through sync failed; see Monitoring
Stale dataConnector Health list (Stale, Failed); assert_staging_not_stale; last Pipeline Run status
dbt test failuredbt_init test --select <test>; read the SQL in dbt_project/tests/
Build never startsan active Pipeline Run or Build Approval holds the single-flight lock; wait for the reapers or cancel it
Slow queriesSELECT * FROM system.query_log WHERE type = 'QueryFinish' ORDER BY query_duration_ms DESC LIMIT 10
Deploy stops at FRAPPE_BRANCH.env pins version-15; see the upgrade path

Scheduled tasks​

TaskFrequencyMethod
Connector health refreshevery 5 minFrappe scheduler, refresh_connector_health
Due Pipeline Schedulesevery minuteFrappe scheduler, run_due_schedules
Stale run and approval reapersevery 10-15 minFrappe scheduler
Unclaimed TB submission cleanupdailyFrappe scheduler, reap_unclaimed_submissions
ERP extract and dbt buildper Pipeline Schedule, or on demandPipeline Run
Backup (MariaDB, ClickHouse, sites)nightlyhost cron, ./deploy.sh backup

Next steps​