Observability
A self-hosted deployment tells you what it is doing in four ways: container
logs, coded error records you can send to a tracker, the pipeline report from
remember ops inspect, and a cost export of every billed model call. None
of them sends anything off the machine unless you configure it to.
Logs
Every container writes to standard output, which Docker keeps:
docker compose logs -f api
docker compose logs -f worker-llm
docker compose logs --since 1h- The API writes an access log line per request.
- Each worker writes one JSON line per item it runs: an event named
worker.runwith anoccurred_attime and anattributeslist holdingdeployment_id,processing_id,stage,lane,attempt,outcomeandduration_ms. An item that ran also hasobject_bytes_readandobject_bytes_written: the bytes it read from and wrote to the S3 object store (with the bundled SeaweedFS or any other S3 store). Summed perstage, they show which stages move the most data to and from storage. The outcome is one ofsucceeded,retry_scheduled,dead_lettered,budget_parked,no_route_parked,admission_parked(a metered deployment's conversion waiting for its control plane's approval),lease_lostorno_work.lease_lostmeans the worker took longer than its hold on the item without renewing it, the item was handed back to the queue, and this run's result was discarded. A failure adds anexceptionobject with the error type, message and full traceback.
An error message can quote the input that caused it, so treat worker logs as containing document text. Log retention and rotation are Docker's; set them with a Docker logging driver.
For the state of the pipeline as a whole (what is pending, what has failed
for good), use remember ops inspect; see
Operating the pipeline.
Errors
What the engine reports
At the places listed below, an unexpected failure ends one of two ways:
- It is raised. It leaves the engine as an exception, and whatever runs the engine reports it: Uvicorn's error log for a request, the process exit for a command.
- It is logged once at ERROR. When the engine turns the failure into a
response, a skipped item or a fallback, it logs one record on a
rememberstack.*logger, at the point where it does so.
Expected outcomes, such as a retry that will run again or a busy graph, are
logged at WARNING. Every such record carries a stable code in error_code,
for example worker_item_failed or graph_query_failed. A code starts with
a lowercase letter, then lowercase letters, digits and underscores, 3 to 64
characters in all, and stays the same across releases; a renamed or removed
code is listed in the changelog. The worker runner's records (item
failures, retries and leases), live graph records and metering records use a
fixed message, with identifiers such as processing_id, stage,
attempt or sqlstate as separate fields on the record. Query sandbox
errors use the exception type and SQLSTATE without including SQL or values.
A worker item's failure, a model provider failure on a request and a live
graph query failure can carry your content in their text: a provider's error
can quote the request, and a database error can quote a query's values.
Those records (the worker item records, provider_call_failed and
graph_query_failed) hold only the exception's type, in exception_type,
and no traceback; so do the worker's worker_finalizer_failed and
provider_usage_unrecorded records. An MCP tool failure keeps the exception
and its traceback.
The main places the engine logs:
| Where | Code | Level |
|---|---|---|
| A worker item fails and will be retried | worker_item_retry | WARNING |
| A worker item fails with no retry left, or cannot be retried | worker_item_failed | ERROR |
| An expired lease is requeued / dead-lettered | worker_lease_expired_retry / worker_lease_expired | WARNING / ERROR |
| A run finishes after losing its lease | worker_lease_lost | WARNING |
| A model provider call fails on a request (503) | provider_call_failed | ERROR |
| A live graph query times out or loses its connection (503) | graph_query_failed | ERROR |
| A live graph result no longer matches its rows (503) | graph_hydration_mismatch | ERROR |
| The live graph has no free slot (503) | graph_capacity_exhausted | WARNING |
| A query consumes a database failure | query_database_failed | ERROR |
| A query sandbox dependency fails | query_dependency_unavailable | ERROR |
| A read reaches its database budget | query_budget_exceeded | WARNING |
| A query search projection is unavailable | search_projection_unavailable | WARNING |
| Model-based document structuring falls back | structure_fallback | ERROR |
| The document skeleton check fails | skeleton_check_failed | ERROR |
| Section title role classification fails | section_roles_failed | ERROR |
| A section summary cannot be generated | summary_failed | ERROR |
| Profile refresh after document archive fails | profile_refresh_failed | ERROR |
| A synchronization item fails | sync_item_failed | ERROR |
| A Vertex stream reports usage the engine cannot parse | provider_usage_unparsed | ERROR |
| A native storage capture scope fails | The declared refusal code or storage_capture_failed | ERROR |
| A spend lease cannot be reserved or committed | spend_lease_unavailable / spend_lease_commit_failed | ERROR |
| The perimeter fails while authenticating a request | perimeter_auth_failed | ERROR |
| A signing-key or revocation refresh keeps the last accepted state after a failure | perimeter_refresh_failed | WARNING |
| An MCP tool fails unexpectedly | mcp_tool_failed | ERROR |
| The control plane rejects the meter's producer credential | meter_receipt_unauthorized | ERROR |
| The control plane is unavailable; the receipt is retried | meter_receipt_retry | WARNING |
| A receipt conflicts with the recorded one | meter_measurement_quarantined / meter_receipt_conflict | ERROR |
Forwarding is off by default: the engine sends nothing anywhere itself. To
collect these records, attach a handler to the rememberstack logger, as
below.
Sentry, GlitchTip or Bugsink
For coded failures, use the Sentry SDK's Python logging integration. The
built-in reporter configured by REMEMBERSTACK_SENTRY_DSN omits
error_code and skips worker-loop logs. See the
configuration reference for
its settings. The setup, api and worker
processes report through the built-in reporter. It keeps the exception type
and stack frames, replaces the message with [redacted], and drops request
data, breadcrumbs, frame locals and extras. Worker attempt events include
stage and processing_id tags, plus lane when available.
Leave REMEMBERSTACK_SENTRY_DSN unset and initialise the SDK in a bootstrap module (see Where the setup runs):
import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
sentry_sdk.init(
dsn="https://…",
send_default_pii=False,
integrations=[LoggingIntegration(level=None, event_level=logging.ERROR)],
)Sentry's logging integration then sends each ERROR record, with its fields,
as an event. This replaces the adapter's metadata-only filtering: by
default the event includes the exception text and frame local variables.
Use the SDK's before_send hook and its include_local_variables=False
option if your policy needs metadata only.
PostHog
A short handler sends each ERROR record to PostHog Error Tracking, with the code as a property:
import logging
from posthog import Posthog
client = Posthog("phc_…", host="https://eu.i.posthog.com")
class PostHogErrors(logging.Handler):
def emit(self, record: logging.LogRecord) -> None:
code = getattr(record, "error_code", "uncoded")
error = record.exc_info[1] if record.exc_info else RuntimeError(code)
client.capture_exception(
error,
distinct_id="rememberstack",
properties={"error_code": code, "logger": record.name},
)
logging.getLogger("rememberstack").addHandler(PostHogErrors(level=logging.ERROR))PostHog's SDK also sends the exception's message. If your policy allows
metadata only, drop it in the client's before_send hook. PostHog also accepts OpenTelemetry
logs at https://eu.i.posthog.com/i/v1/logs, with your project token as a
bearer token, which feeds PostHog Logs rather than Error Tracking; see
PostHog's logs setup.
OpenTelemetry
OpenTelemetry can export Python logs with error_code as a log attribute.
For a Compose deployment, build an image with the instrumentation packages
that match the engine's OpenTelemetry SDK. This example uses SDK 1.44.0
and its matching instrumentation release 0.65b0.
# Dockerfile.otel
FROM ghcr.io/writeitai/remember-stack:0.21.3
USER root
RUN uv pip install --python /app/.venv/bin/python --no-deps \
opentelemetry-distro==0.65b0 \
opentelemetry-instrumentation==0.65b0 \
opentelemetry-instrumentation-logging==0.65b0 \
'wrapt<3'
USER appPoint the logs exporter at your Collector's OTLP HTTP receiver. This override instruments the API. Apply the same image, build and entrypoint to each worker service you want to collect. Compose passes each service's existing command to the instrumented entrypoint.
# compose.override.yaml
services:
api:
image: rememberstack-otel:local
build:
context: .
dockerfile: Dockerfile.otel
entrypoint: ["opentelemetry-instrument", "python", "-m", "rememberstack.profiles.selfhost"]
environment:
OTEL_SERVICE_NAME: rememberstack-api
OTEL_LOGS_EXPORTER: otlp
OTEL_TRACES_EXPORTER: none
OTEL_METRICS_EXPORTER: none
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: https://collector.example:4318/v1/logsRun docker compose up -d --build api. When an engine request fails with
provider_call_failed, find the record from rememberstack-api in your
Collector's destination and filter its log attributes by
error_code=provider_call_failed. A Collector with the debug exporter
at detailed verbosity shows the attribute in its own logs. See the
OpenTelemetry Collector logs example.
Or attach the SDK's handler in a bootstrap module:
import logging
from opentelemetry._logs import set_logger_provider
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
provider = LoggerProvider()
provider.add_log_record_processor(BatchLogRecordProcessor(OTLPLogExporter()))
set_logger_provider(provider)
logging.getLogger("rememberstack").addHandler(
LoggingHandler(level=logging.ERROR, logger_provider=provider)
)The record's fields, error_code among them, become log attributes.
Where the setup runs
Add a handler before the engine starts, in a small module that then runs
the engine's own command. Keep a handler that writes to standard output, so
docker compose logs still works: adding any handler turns off Python's
fallback output.
# bootstrap/remember_logging.py
import logging
import sys
from rememberstack.profiles.selfhost import main
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
# … attach the tracker handler from one of the sections above …
sys.exit(main(sys.argv[1:]))Mount it and use it as the entrypoint for each service, in a
compose.override.yaml next to compose.yaml:
# compose.override.yaml
x-bootstrap: &bootstrap
entrypoint: ["python", "/bootstrap/remember_logging.py"]
volumes:
- ./bootstrap:/bootstrap:ro
services:
api: *bootstrap
worker-convert: *bootstrap
worker-llm: *bootstrapEach service keeps its own command. Install your tracker's package in an
image built on the engine's, or add it to the mounted directory and put that
directory on PYTHONPATH.
Model-call tracing
A self-hosted deployment does not trace model calls. The LANGFUSE_* and
REMEMBERSTACK_LANGFUSE_* variables are read only by the project's
benchmark harness; setting them for the API and workers changes nothing.
What you can see of each model call is its cost receipt, below.
Cost export
Every billed provider call, by a worker or by the API (for example the embedding of a search query), is written to a cost ledger with its model, tokens, cost in US dollars and where it came from. The cost export reads that ledger. It contains no document text and no prompts.
From the command line
DEPLOYMENT_ID=$(grep '^REMEMBERSTACK_SELFHOST_DEPLOYMENT_ID=' .env | cut -d= -f2)
docker compose exec -T api \
remember ops cost-export --deployment "$DEPLOYMENT_ID" --limit 100Pass the page's next_cursor as --cursor to read the next page. The
command exits with status 2 if --deployment is not this deployment's id or
the cursor is malformed.
Over HTTP
The API process can serve the same export on a second address, separate from the memory API. It is off unless you give it an address and a token:
| Variable | Meaning |
|---|---|
REMEMBERSTACK_COST_EXPORT_BIND | Where to listen: host:port, [ipv6]:port or unix:/path/to/socket. Unset means no HTTP export. |
REMEMBERSTACK_COST_EXPORT_TOKEN | The bearer token callers must send. At least 32 bytes; the API refuses to start with a shorter one once the bind is set. |
Set both in .env, and publish the port with a compose.override.yaml
next to compose.yaml, which Compose merges automatically:
# .env
REMEMBERSTACK_COST_EXPORT_BIND=0.0.0.0:8001
REMEMBERSTACK_COST_EXPORT_TOKEN=<output of: openssl rand -hex 32># compose.override.yaml
services:
api:
ports:
- "127.0.0.1:8001:8001"The extra port is added to the API's existing one.
The bind is an address inside the container, so it must be 0.0.0.0 for
the published port to reach it.
curl -H "Authorization: Bearer $COST_EXPORT_TOKEN" \
"http://127.0.0.1:8001/ops/cost-export/v1?limit=100"| Parameter | Default | Range |
|---|---|---|
limit | 100 | 1–500 |
cursor | none (start from the beginning) | a next_cursor from an earlier page |
| Status | Meaning |
|---|---|
401 | Missing or wrong token |
422 | Malformed cursor |
429 | More than one request per second |
The page
{
"contract": "rememberstack.cost_export.v1",
"deployment_id": "…",
"server_time": "2026-09-23T10:15:00Z",
"horizon": "2026-09-23T10:14:00Z",
"cursor": "…",
"next_cursor": "…",
"persist_failures": 0,
"scope_missing": 0,
"receipts": [
{
"cost_id": "…",
"deployment_id": "…",
"source": "worker",
"work_id": "…",
"stage": "extract_claims",
"lane": "steady",
"attempt": 1,
"surface": null,
"call_key": "…",
"outcome": "…",
"model_name": "openai/gpt-6-luna",
"tokens_in": 5120,
"tokens_out": 830,
"cost_usd": "0.0041",
"latency_ms": 2300,
"occurred_at": "2026-09-23T10:02:11Z"
}
]
}sourceisworkerfor pipeline calls, which carrystage,laneandattempt, orsurfacefor calls made while answering a request, which carrysurfaceinstead.cost_usdis a decimal string, ornullwhen the provider reported no cost.- A page includes only receipts older than
horizon, which is 60 seconds beforeserver_time, so a receipt still being written never appears and then changes. - Keep the last
next_cursorand poll with it later to read only new receipts. persist_failuresandscope_missingcount request-time costs that could not be written to the ledger. Non-zero means the export under-reports.
Health and provenance
GET /healthz answers {"status":"ok"} when the API reaches PostgreSQL.
It needs no token, and Compose uses it as the API's health check.
GET /deployment reports build_revision (the source commit the image
was built from, empty for a local build), model_bindings (the model on
each pipeline seat and the OpenRouter routing settings) and
document_binding_generation, and the MCP memory tools it serves
(tools). It needs a read or write credential when authentication is
on.