Observability
These pages list what a running kōjō exposes about itself: OpenTelemetry traces, Prometheus metrics, logs, health endpoints, session replay, cost per session and the audit log. They are for operators who monitor a deployment and for anyone who needs to find out what a session did.
This page covers the endpoints, traces, logs, health and readiness, session replay and cost accounting. Three pages cover the rest:
- Prometheus metrics: every metric on
/metricswith its labels and buckets, the merge and human-edit rates, and example queries and alerts. - Audit log: what an entry holds, every action recorded, how the table stays append-only, and how to read and export it.
- Shareable reports: a read-only, redacted page of one session that anyone with its link can open without signing in, which pull request descriptions link.
Endpoints at a glance
kojo serve answers these on server.listen (default :8080). None of the three needs authentication, so do not expose the port to networks that should not read them.
| Endpoint | Purpose |
|---|---|
GET /healthz |
Liveness. Always 200 ok while the process serves HTTP. |
GET /readyz |
Readiness. 200 ready when Postgres answers a ping within 3 seconds, otherwise 503. |
GET /metrics |
Prometheus metrics, on server.metrics_listen (default 127.0.0.1:9090), not on the main port. |
The proxy has its own GET /healthz, see health and readiness.
Session data and the audit log are served by the JSON API under /api/v1, which does need a signed-in user or an API token. See session replay and audit log.
OpenTelemetry traces
kōjō exports traces over OTLP/HTTP. It exports no metrics and no logs over OTLP: metrics are Prometheus only, logs go to stderr.
Tracing is set up by kojo serve only. kojo proxy and kojo eval --local do not export traces.
Turning it on
Tracing is off until an endpoint is named, in kojo.yaml or in the environment.
| Setting | Where | Meaning |
|---|---|---|
telemetry.otlp_endpoint |
kojo.yaml |
OTLP/HTTP endpoint traces are sent to: a base URL or a full URL. No default. |
telemetry.service_name |
kojo.yaml |
The service.name resource attribute. Default kojo. |
OTEL_EXPORTER_OTLP_ENDPOINT |
environment | Standard OpenTelemetry variable. Turns tracing on when telemetry.otlp_endpoint is empty. |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT |
environment | Same, for traces only. |
telemetry:
otlp_endpoint: http://otel-collector:4318
service_name: kojo
telemetry.otlp_endpoint takes a base URL or a full URL. A base URL (no path, or only /) gets the standard traces path, so the example above sends to http://otel-collector:4318/v1/traces. A URL that already has a path is used as written. OTEL_EXPORTER_OTLP_ENDPOINT behaves the same way for a base URL: the exporter appends /v1/traces itself, as the OpenTelemetry specification says:
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318 kojo serve
When both are set, telemetry.otlp_endpoint wins. An http:// URL sends without TLS. The exporter also reads the other standard OTEL_EXPORTER_OTLP_* variables, for example OTEL_EXPORTER_OTLP_HEADERS for a collector that needs a token. The other keys of kojo.yaml are in the kojo.yaml reference.
Every span carries the resource attributes service.name (from telemetry.service_name) and service.version (the kōjō version). Spans are sent in batches and flushed at shutdown. kōjō sets no sampler, so the SDK default applies.
What is traced
The engine starts two kinds of span, with the tracer name github.com/xavidop/kojo/internal/core.
| Span name | Started | Attributes |
|---|---|---|
session |
Each time a worker runs a claimed session. | kojo.session, kojo.repo, kojo.trigger, and kojo.status when the run ends |
subagent <skill> |
Each time the orchestrator delegates to a skill, for example subagent fix-bug. |
kojo.skill |
A subagent span is a child of its session span. A session that pauses for an approval, or is picked up again after a restart, gets a new session span in a new trace when a worker resumes it; kojo.status on the earlier span is then a status that is not final, such as waiting. Use the kojo.session attribute to find every trace of one session.
The embedded model gateway is built on Genkit, which uses the same global tracer provider, so the spans Genkit emits for model calls land in the same trace as the session.
The names and attributes of the Genkit spans are set by Genkit, not by kōjō. They are not listed here and may change with the Genkit version.
Not traced: incoming HTTP requests (webhooks, API, dashboard), tool calls, sandbox commands and proxy decisions. For those, use session replay, the audit log and the metrics.
Logs
Every command logs to stderr with Go’s structured logger. Two global flags control it, each with an environment variable.
| Flag | Environment | Default | Values |
|---|---|---|---|
--log-level |
KOJO_LOG_LEVEL |
info |
debug, info, warn, error. An unknown value means info. |
--log-format |
KOJO_LOG_FORMAT |
text |
text (key=value pairs) or json (one object per line). Anything other than json means text. |
kojo serve --log-format json --log-level debug
KOJO_LOG_FORMAT=json KOJO_LOG_LEVEL=warn kojo serve
Every line has time, level and msg. The other fields depend on the line:
| Field | On | Meaning |
|---|---|---|
session, repo |
Lines written while a session runs. | The session ID and its repository. |
err |
Error and warning lines. | The error text. |
forge, remote, kind |
Webhook lines. | The forge, the sender’s address, the event kind. |
method, path |
API errors (msg=api). |
The request that failed. The client only sees internal error; the detail is here. |
action |
msg="audit write failed". |
The audit action that could not be written. |
schedule, sessions |
msg="schedule fired". |
The schedule and how many sessions it started. |
listen, public_url, driver, models, version |
The start line of kojo serve. |
What the server started with. |
The proxy logs one line per decision at debug level: msg="proxy decision" with sandbox, method, host, decision, intercepted and injected (the names of the credentials set on the request). Header values and tokens are never logged. Failed upstream requests are logged at warn with sandbox, host and error.
A standalone kojo proxy also logs every refused request at warn level: msg="egress refused" with sandbox, host, method and reason (denied_host, unauthenticated, blocked_address or too_many_connections). It has no audit log entries and no metrics, so these lines are the record of refused egress in remote mode. The embedded proxy writes an audit entry and counts the metric instead.
With a standalone proxy, kojo serve logs at info when a replica has restarted: msg="kojo-proxy restarted" with replica (its admin address), previous and instance (the old and the new instance ID), then msg="sent a kojo-proxy replica a sandbox's policy again" with replica, sandbox and instance for each policy it sent again. A policy it could not send is logged at warn, msg="could not send a kojo-proxy replica a sandbox's policy again" with replica, sandbox and error, and tried again at the next check. A replica that stops answering is logged at warn (msg="a kojo-proxy replica does not answer: ...") and again at info when it answers; with admin_discovery: dns, replicas that appear and go are logged at info. The full list is under kojo-proxy’s logs.
Logs are not shipped anywhere by kōjō. Collect stderr with your container runtime or log agent.
Health and readiness
| Endpoint | Listener | Answer |
|---|---|---|
GET /healthz |
server.listen (default :8080) |
200 with ok. |
GET /readyz |
server.listen |
200 with ready when Postgres answers a ping within 3 seconds. 503 with database unreachable otherwise. |
GET /healthz |
sandbox.proxy.listen (default :3128) |
200 with kojo-proxy ok. Embedded and standalone. |
GET /healthz |
sandbox.proxy.admin_listen (default :3129) |
200 with kojo-proxy ok. Standalone kojo proxy only. No authentication. |
GET /readyz |
sandbox.proxy.admin_listen |
200 once a kōjō server has sent this proxy replica the sandbox policies, or sandbox.proxy.sync_timeout has passed since it started. 503 before. Standalone kojo proxy only. No authentication. |
kojo serve applies pending database migrations before it starts listening, so /readyz cannot answer before the schema is in place.
The Helm chart points the liveness and startup probes at /healthz and the readiness probe at /readyz, for kōjō and for the proxy replicas: a new proxy replica takes no sandbox traffic until kōjō has sent it the policies (see Several replicas). In the compose file the kōjō image has no shell or HTTP client for a container health check: check from outside with curl http://127.0.0.1:8080/readyz.
For a check of the whole deployment (configuration, database, models, sandbox driver, surfaces), run kojo doctor. See the CLI reference.
Session replay
Every session is recorded in Postgres as it runs. Nothing has to be turned on, and replay does not depend on the trace backend.
What is stored
For each session, the sessions table holds:
| Data | Fields |
|---|---|
| The request | Surface, kind, actor, repository, issue or pull request number, the text asked, the skill asked for, dry-run flag. |
| State | status (queued, running, waiting, succeeded, failed, cancelled), error, attempts, timestamps. |
| Usage | cost_usd, tokens_in, tokens_out. |
| What it ran with | revisions (the config revision IDs in effect when it started) and skill_shas (the commits of git-backed skills). |
| Sandboxes | The IDs of the sandboxes the session owns. |
| Result | Outcome, summary, the critic’s report, branch, pull request number and URL, diff, the step that wrote each block of the diff (provenance), risk score with its reasons, outputs, and whether the critic passed it. |
| Checkpoint | The orchestrator’s state after its last completed step. A restarted or resumed session continues from it. |
The checkpoint is internal: the API and the CLI leave it out.
Each action of the session is a row of the steps table. Steps are numbered in order (seq) and form a tree through parent_id. A step has a kind, a name, a status (running, ok, failed), JSON input and output, an error, start and end times, and for model turns the model, tokens and cost.
| Kind | What it records | Input and output |
|---|---|---|
orchestrator |
A model turn of the orchestrator. | Tier and message count in; reply text and tool calls out. |
subagent |
One delegated skill run. | Task, skill layer, revision or commit, tier and tools in; the skill’s result out. |
model |
A model turn of a subagent. | Same as orchestrator. |
tool |
A tool call. | The call’s arguments in; the tool’s result out. |
exec |
A sandbox command: a command the agent ran, a goal check, or a kit setup command (step name kit setup, one step per command). |
Command in; exit code, output and seconds out. A kit setup step has the command in and no output. |
critic |
A goal critic verdict. | The verdict out. |
merge |
The merge policy decision. | The decision and the risk out. |
surface |
A comment, a chat message, a pull request opened or merged. | The number or channel in; the URL or message ID out. |
sandbox |
A sandbox created, or the workspace prepared. | Driver, image, skill, needs_docker and egress allowlist in; sandbox ID and seconds out. |
Model turns store the reply and the tool calls, not the full prompt: the input holds only the tier and the number of messages sent. Long command output is clipped before it is stored.
Steps are deleted only when their session row is deleted. kōjō has no retention job for sessions or steps.
Where each changed line came from
A session’s result links each block of its changed lines to the step that wrote it.
After each tool call that can change the workspace (write_file, edit_file and exec), the core snapshots every repository the session may publish: it commits the tree on the scratch ref refs/kojo/provenance inside the sandbox, with the step’s ID in the message. The commit is made with git commit-tree from an index of its own (.git/kojo-provenance-index), so the working tree, the index, HEAD and the branches do not move, and nothing of it reaches the goal critic’s diff or what is published. A snapshot whose tree did not change makes no commit. Before each attempt of a subagent, and once more before the change is published, the core takes a snapshot that names no step, so what a kit’s setup or a goal check changed is not credited to a tool call. The reference and linked repositories under .kojo/ are left out of the session’s repository’s snapshots; each writable linked repository has snapshots of its own, in its own .git. Each snapshot is one sandbox command: git add -A and git write-tree, then git commit-tree and git update-ref when the tree changed.
When the session ends with a change, git blame over the snapshots maps each added line of the final version to the snapshot that last wrote it, and git blame --reverse maps each removed line to the last snapshot that still had it: the snapshot after that one removed it. Both are cut to the line ranges of the diff, so a file created and deleted again is not mentioned. A step ID read back from a snapshot counts only when it is a tool call of the session. This runs in the sandbox with the sandbox’s git: it is an aid for review, not evidence.
The result keeps it as provenance: for each repository that changed, each changed file with its blocks of added lines (by line number in the new version) and of removed lines (by line number in the old one), each block with its step; and for each step its number, its tool, its skill and its intent. The intent is the purpose the tool call gave (an optional argument of write_file, edit_file and exec), or else the first line of the model’s text in the turn that made the call, or else what the call did, on one line of at most 120 characters. A block with no step was written outside a tool call. A file without blocks (a binary file, a mode change) names the step that last changed it.
| Bound | Value |
|---|---|
| One snapshot | 1 minute |
| Snapshots per session | 1,000 |
| The analysis at the end | 2 minutes and 4 MiB of output per repository |
| Blocks in the result | 2,000; the files past them are listed without blocks and truncated is set |
Provenance never fails a session. When a snapshot or the analysis fails, the recording stops, the change is published as it would have been, and provenance.missing (or a repository’s missing) says why. The pull request’s description lists the blocks with links to their steps, or says why it cannot.
Viewing a session
From a terminal, against a running server (--server, --token):
kojo sessions list --status failed --repo github/acme/api
kojo sessions show ses_01jexample
kojo sessions logs ses_01jexample
kojo sessions logs ses_01jexample --follow
kojo sessions logs ses_01jexample --json
| Command | Prints |
|---|---|
kojo sessions list |
One line per session, newest first: ID, status, repository, trigger, cost, age, title. Flags: --status, --repo, --limit (default 30), --json. |
kojo sessions show |
Status, cost and tokens, then the summary, the critic’s report, the risk, the pull request URL and the diff. --json prints the whole session record. |
kojo sessions logs |
One line per step: skills, commands, tool calls, critic verdicts, sandbox, merge and surface steps. Model turns are not printed. --follow polls every 2 seconds until the session ends or waits for an approval. --json prints every step with its input and output. The two cannot be combined: --follow --json is a usage error. |
In the dashboard, open Sessions and select a session. The page shows status, outcome, cost, tokens, duration and step count, the summary and the critic’s report, the request, the revisions the session ran with, the replay, and the diff. The replay is the steps as a tree with a timing waterfall, filters by kind and text, and a detail panel per step that shows commands with their output. A step that wrote lines of the change is marked with how many, and its detail lists the files and line ranges. In the diff, each block of changed lines links to the step that wrote it. /sessions/<id>?step=<step id> opens the page at that step, unfolded and open: the links of a pull request’s description point there when the session has no shareable report. Share makes a link to the session’s report for people without a dashboard account. The page refreshes every 3 seconds while the session is active. The dashboard itself is described in The dashboard.
The same data is available from the API to any identity with the viewer role:
| Endpoint | Returns |
|---|---|
GET /api/v1/sessions |
Sessions, newest first, each result without its diff and provenance. Query: status, repo, surface, since (RFC 3339), before (a session ID, for paging), limit (default 50, at most 200). |
GET /api/v1/sessions/{id} |
One session, without its checkpoint. |
GET /api/v1/sessions/{id}/steps |
Every step of the session, in order. |
GET /api/v1/stats |
The last 7 days: sessions by status, pull requests, spend over 7 days and over 24 hours, budgets, and the critic’s pass rate per skill. |
curl -H "Authorization: Bearer $KOJO_TOKEN" "$KOJO_SERVER/api/v1/sessions/ses_01jexample/steps"
Cost accounting
Each model call is priced with the price configured for its tier:
cost_usd = (tokens_in × input_per_mtok + tokens_out × output_per_mtok) / 1,000,000
A tier without a price costs 0. Prices, budgets and what happens when a budget is reached are covered in Models.
The cost is stored in three places:
| Level | Where | Shown by |
|---|---|---|
| Model call | The step: model, tokens_in, tokens_out, cost_usd. |
kojo sessions logs --json, the replay’s step detail. |
| Session | The session: cost_usd, tokens_in, tokens_out, the sum of its model calls. |
The COST column of kojo sessions list, kojo sessions show, the session page, the session.end audit entry. |
| Deployment | The sum of step costs over a time window. | cost_usd_24h and cost_usd_7d of GET /api/v1/stats (the dashboard’s overview), and the kojo_session_cost_usd_total and kojo_model_cost_usd_total metrics. |
The daily budget uses the same sum: the cost of every step started in the last 24 hours, as a rolling window.