Skip to main content

Monitoring

What to watch on a running stack, and what each signal means. Code references are to konsol/api.py, konsol/clickhouse.py, konsol/pipeline/doctype/connector_health/ and dbt_project/tests/assert_staging_not_stale.sql on 2026-11-05.

Health endpoint​

curl -s -H "Host: konsolidat.local" http://localhost:8069/api/method/konsol.api.health
# {"message": {"status": "ok", "app": "konsol",
# "clickhouse": {"status": "healthy", "clickhouse_reachable": true,
# "recent_sync_failures": [], "message": "All systems operational"}}}
  • Guest-accessible; no login needed. Through Caddy the Host header is set for you.
  • konsol.api.health calls konsol.clickhouse.check_health, which runs SELECT 1 against the ClickHouse connection in EPM Settings and reports the write-through tables whose last sync failed.
  • Top-level status: ok (ClickHouse answers, no sync failures), degraded (answers, but one or more tables have a recorded sync failure), down (unreachable or error). The clickhouse.message field is one of All systems operational, N table(s) have sync failures, ClickHouse is unreachable, or ClickHouse error: ....
  • The sync-failure list is held in the web worker's memory, so it reflects failures seen by that process since it started. Use the Error Log in Desk for the full record.

Point your uptime monitor at https://<SITE_DOMAIN>/api/method/konsol.api.health. Expect HTTP 200 with "status": "ok"; alert on a non-200, a timeout, or degraded or down for more than a few minutes. The API reference has the full response shape.

End-to-end query check​

curl -c cookies.txt -X POST http://localhost:8069/api/method/login \
-H "Host: konsolidat.local" -H "Content-Type: application/json" \
-d '{"usr": "Administrator", "pwd": "<ADMIN_PASSWORD>"}'
curl -b cookies.txt -H "Host: konsolidat.local" \
"http://localhost:8069/api/method/konsol.api.epm_value?entity=<ENTITY>&year=2025&period=1&account=<ACCOUNT>"

A numeric value proves the Frappe to ClickHouse to gold path for a logged-in user. Use an entity code and account that exist on your site; there is no demo data.

Connector health​

Each enabled Connector has one Connector Health row (Desk list, or the API below). The row is derived; nobody edits it. The scheduler job refresh_connector_health rebuilds it every 5 minutes from the Connector's webhook-fed last_sync_* fields plus a live count of entities in epm_staging.stg_gl_entries.

curl -b cookies.txt -H "Host: konsolidat.local" \
http://localhost:8069/api/method/konsol.api.connector_health

connector_health needs read permission on Connector Health (System Manager, EPM Admin, EPM Analyst, EPM User) and returns one object per connector: connector, erp_source, last_sync_status, lag_minutes, entities_loaded, rows_emitted, last_sync_end, last_error, checked_at, ordered by lag.

last_sync_statusMeaning
NeverNo sync has reported yet
RunningAirbyte reported Running and the threshold has not passed
SucceededLast sync Success or Partial, within the threshold
FailedLast sync reported Failed
StaleNo successful sync for longer than the connector's Expected Sync Frequency (Minutes) (sync_frequency_minutes, default 1440), or a sync stuck in Running past it

Failed and Stale are the states that alert operators. entities_loaded of 0 is not by itself unhealthy; a connector may sync master data only.

How sync status arrives​

Airbyte calls the webhook konsol.api.airbyte_sync_complete when a sync finishes. It accepts a logged-in session or the shared secret in the X-Webhook-Secret header (EPM Settings, webhook_secret; compared in constant time). It writes last_airbyte_sync_at, last_airbyte_sync_status (Success, Failed, Partial, Running) and last_airbyte_sync_rows to EPM Settings, and when the payload names a connection_id that matches a Connector's airbyte_connection_id, to that Connector too. Build Governance preflight reads the per-connector status.

If the webhook is not configured in Airbyte, every connector stays Never, and later Stale.

Sync watermarks and LAGGING​

konsol stamps epm_staging.sync_watermark (table_name, synced_at, row_count, source_max_modified, reconcile_run_id) every time it writes a reference table to ClickHouse. reconcile_all (run after every bench migrate) stamps every table it writes with one run id; an ordinary document save stamps ''.

The dbt test assert_staging_not_stale reads the watermark on every build and fails with one of three reasons:

ReasonMeaningWhat to do
EMPTIEDThe watermark promises rows the table no longer has: a wiped ClickHouse, a restore in the wrong order, a half-finished migrationRun reconcile_all, then rebuild
LAGGINGThe table has no row from the latest settled reconcile run, so that run did not reach it (konsolidat#246, decided 2026-10-11). A table a document save refreshed since still counts as LAGGING: the question is whether the reconcile reached it, not whether it is recentRead the Error Log for the failed sync, fix the cause, run reconcile_all
NO_RECONCILE_RUNNo reconcile has stamped a run id yet. Allowed for lag_hours after the reconcile_run_id column appeared (an upgrading site), then failsRun reconcile_all

Before konsolidat#246, LAGGING meant "older than the newest watermark of any table", and publishing one Reporting Hierarchy made 26 untouched tables look stale. The alternatives rejected were dropping LAGGING (#246-2) and raising the lag hours (#246-3).

SELECT table_name, max(synced_at) AS synced_at, argMax(row_count, synced_at) AS rows,
argMax(reconcile_run_id, synced_at) AS run
FROM epm_staging.sync_watermark GROUP BY table_name ORDER BY synced_at;

Pipeline and close status​

  • Pipeline Run list: status Queued, Extracting, Transforming, Running, Completed, Failed, Cancelled; heartbeat_at and duration_seconds; the Log tab holds the dbt output. A run with no heartbeat is released by reap_stale_runs (every 15 minutes).
  • Assertion Run list: the close checks per period with passed, failed, warned, errored and the sign-off state. Stuck runs are released by reap_stale_close_runs (every 10 minutes).
  • Error Log (Desk): every failed sync, reconcile and job writes here.
  • deploy.sh step 5 fails the deploy on a compilation or database error and tolerates data-quality test failures; read its output when a deploy ends with dbt build had test failures.

Docker health checks​

Defined in docker-compose.yml:

ServiceCheck
mariadbhealthcheck.sh --connect --innodb_initialized, every 10 s
redis_cache, redis_queueredis-cli ping, every 5 s
clickhouseclickhouse-client --password "$CLICKHOUSE_PASSWORD" --query 'SELECT 1', every 10 s
frappe_backendcurl -sf -H "Host: $SITE_NAME" http://localhost:8069/api/method/ping, every 15 s after a 30 s start period
docker compose ps
docker inspect --format='{{.State.Health.Status}}' konsolidat_clickhouse

scripts/healthcheck.sh (make test) curls ClickHouse /ping, system.databases and Frappe /api/method/ping from the host.

Logs​

Every container's Docker log is capped at 3 files of 100 MB (x-logging). Read them with Compose:

docker compose logs -f --tail=100 frappe_backend
docker compose logs --since 1h frappe_worker frappe_scheduler
docker compose logs --tail=200 clickhouse

Frappe's own log files are in the frappe_logs volume, at /home/frappe/frappe-bench/logs inside the Frappe containers (docker compose exec frappe_backend tail -f logs/worker.log). ClickHouse server logs are in the clickhouse_logs volume; system.text_log and system.query_log are queryable:

SELECT event_time, message FROM system.text_log
WHERE level = 'Error' AND event_time > now() - INTERVAL 1 DAY ORDER BY event_time DESC LIMIT 20;

SELECT query_start_time, query_duration_ms, read_rows, formatReadableSize(read_bytes) AS data_read, query
FROM system.query_log
WHERE type = 'QueryFinish' AND query_start_time > now() - INTERVAL 1 HOUR
ORDER BY query_duration_ms DESC LIMIT 10;

ClickHouse capacity​

SELECT database, formatReadableSize(sum(bytes_on_disk)) AS disk_size,
formatReadableQuantity(sum(rows)) AS total_rows, count() AS parts
FROM system.parts WHERE active AND database LIKE 'epm%'
GROUP BY database ORDER BY sum(bytes_on_disk) DESC;

Watch host disk too (df -h /var/lib/docker): the 2026-10-06 outage was a full disk, not a full table.

Alert thresholds​

These are operating targets, not enforced by the stack (PRD Production Hardening is not started). Prometheus and Grafana are not part of the deployment today.

MetricWarningCritical
konsol.api.healthdegradeddown, non-200, timeout
Connector Healthany Staleany Failed
assert_staging_not_stale-any LAGGING or EMPTIED row
Pipeline Runlonger than usualFailed, or no heartbeat
API response timeover 2 sover 10 s
ClickHouse query timeover 5 sover 30 s
Host diskover 70 percentover 90 percent
Backup cron log-backup does not build line, or no new directory

Next steps​