Skip to content

Observability ​

agent-orca exposes standard Kubernetes-style probes, Prometheus metrics, and structured audit logging on every external HTTP surface.

Health probes ​

All probes are unauthenticated (publicPaths in internal/apiserver/auth.go).

EndpointPortPurpose
GET /healthz8084, 8000Liveness — returns 200 if the server process is alive
GET /readyz8084, 8000Readiness — checks K8s API connectivity and Redis (if configured)
GET /version8084, 8000Returns build version, commit, and uptime
GET /metrics8084, 8000Prometheus-format metrics
bash
curl http://localhost:8084/healthz
curl http://localhost:8084/readyz
curl http://localhost:8084/version
curl http://localhost:8084/metrics

Prometheus metrics ​

Metrics are served from a dedicated registry (externalReg in internal/apiserver/metrics.go) so they don't collide with the controller-runtime manager metrics on :8443.

HTTP API metrics ​

MetricTypeLabelsDescription
agentorca_external_requests_totalCounterserver, path, method, statusTotal HTTP requests to external API surfaces
agentorca_external_request_duration_secondsHistogramserver, pathRequest latency distribution
agentorca_external_auth_failures_totalCounterserverFailed authentication attempts

Egress metrics ​

MetricTypeLabelsDescription
agentorca_egress_published_totalCountersink_typeSuccessfully published results to egress sinks
agentorca_egress_failed_totalCountersink_typeFailed egress publishes

Model-router metrics ​

Each run's model-router serves these on :9091 (see Reaching agent-pod metrics behind the NetworkPolicy).

MetricTypeLabelsDescription
agentorca_modelrouter_spend_usd_totalCounternamespace, run, provider, model, outcomeUSD spent on LLM calls, by how the call ended
agentorca_modelrouter_llm_tokens_totalCounterdirection (prompt/completion), providerTokens providers reported (the billed figures)
agentorca_modelrouter_llm_latency_secondsHistogramproviderRouting a call to the end of its response stream
agentorca_modelrouter_llm_ttft_secondsHistogramproviderRouting a call to its first token
agentorca_modelrouter_llm_errors_totalCounterprovider, classFailed calls (rate_limited, provider_5xx, provider_4xx, timeout, request_too_large, cancelled, stream_interrupted, provider_error)
agentorca_modelrouter_routing_decisions_totalCounterstrategy, path, stageSelections, by the path that made them and the task stage. Paths: rule:* (the rule router; capability rules report as rule:capability), meta / meta-cache, fallback, switchyard, and switchyard-failopen (Switchyard could not decide and the rule router did)
agentorca_modelrouter_routing_fallbacks_totalCounterfrom, toCalls served by a fallback after another provider failed
agentorca_modelrouter_tool_calls_totalCounterTool calls the router dispatched
agentorca_modelrouter_stream_duration_secondsHistogramDuration of a streaming chat response
agentorca_modelrouter_telemetry_events_dropped_totalCounterRouting events dropped because the operator was unreachable and the queue was full
agentorca_modelrouter_tokens_totalCounterStreamed output bytes, a live gauge for the UI; use llm_tokens_total for real token counts

Routing telemetry ​

With PostgreSQL configured, every LLM call a router makes also becomes a row in routing_events: the provider and the deciding path, the task stage, tokens, cost, latency and time to first token, any fallback or error, and how its tool calls went. It holds metadata only, never prompts or responses. Each run's outcome (phase, failure class, turns, cost, tool-approval rejections) is written to run_outcomes when the run is archived. Later routing work reads these tables to judge whether a routing choice was worth its cost.

  • Rows older than --routing-events-retention (default 720h, 0 keeps them) are deleted by the operator.
  • Without PostgreSQL the operator acknowledges and drops posted events; the metrics above still work, and a run's page shows the latest 100 routing decisions kept in status.routingDecisions.
  • GET /api/runs/{namespace}/{name}/routing-events returns a run's full history, oldest first (the run page's "Load full history").
  • GET /api/routing-events lists decisions across runs, newest first, with the filters namespace, agent, selector, outcome (ok, error, fallback), shadow=true, since, until and limit. Both endpoints return only the caller's tenant's rows: the store filters on tenant_id and row-level security (see tenant isolation) backs it, and a tenant without a namespace filter is limited to its own namespaces. The retention sweep runs in the platform scope, so it still deletes the old rows of every tenant.

Controller metrics ​

The controller-runtime manager exposes additional metrics on :8080 in the Helm chart (--metrics-bind-address=:8080 --metrics-secure=false; kubebuilder scaffold default is :8443 over HTTPS) — these are server-internal and not on the external API surfaces. They include standard Kubernetes controller metrics (reconciliation counts, errors, workqueue depth, etc.). These are the metrics served by the <release>-metrics Service and scraped by the chart's ServiceMonitor.

Archived run retention ​

With PostgreSQL configured, every finished run is archived in archived_runs. The heavy part of a row is its output, raw output and execution trace (trace_events), which can also hold personal data a user typed or an agent read. By default nothing is ever removed. Set ARCHIVED_RUNS_RETENTION_DAYS (Helm database.archivedRunsRetentionDays, default 0, which keeps everything) to reduce old rows.

The leader operator sweeps every 6 hours (and at startup). For each archived run that finished, and was last written, more than that many days ago, it sets output, raw_output and trace_events to empty and stamps payload_pruned_at. The row itself is kept.

StaysIs lost
Status, phase, restart count, timestampsThe final output and raw output
spend_usd, cost capture, token countsThe execution trace (tokens, tool calls and results) shown on the run page
Routing decisions (the cost dashboard reads the model from them) and child run references
The input, labels, agent and tenant
run_outcomes and feedback ratings
  • Cost totals do not change. The cost dashboard, the fleet view and the history list read only the columns that stay. The run page tells the user that output and trace were removed, and when (payloadPrunedAt on GET /api/runs/history/{namespace}/{name}).
  • The input is kept. History search and "add to dataset" need it. If the input itself is the sensitive part, retention here does not remove it.
  • Evaluation datasets are not affected. A case copies the run's input (redacted unless the user chose otherwise) and any reference when it is created, and keeps only the run's name for provenance. It never reads the archive again, so a case stays complete after its source run is reduced. What you can no longer do is add a reduced run to a dataset using its output as the reference (the API answers 409, as for a run with no output).
  • Routing events have their own retention. --routing-events-retention (default 30 days) deletes routing_events rows (metadata only, no prompts). The two do not depend on each other. A reduced run keeps its routing decisions even after its routing events are gone, and the per-run "Load full history" only shows what routing events still exist.
  • A reduced run stays reduced. The operator archives every finished run again when it restarts, from the live AgentRun, which may still hold its output. For a row that was reduced, that write leaves the payload empty and keeps payload_pruned_at. For a row that was not, an archive that changes nothing (same phase, output, spend and times) does not move updated_at, so a restart does not postpone the sweep; one that changes something does, and the sweep takes the row once it has been quiet for the retention period.
  • It is cluster-wide. There is no per-tenant override. The sweep runs in the platform scope, like routing events retention; a tenant cannot trigger or skip it.
  • The change is not reversible: PostgreSQL backups taken earlier still hold the old payloads until they expire.

agentorca_archived_runs_swept_total counts the rows reduced. The sweep works in batches of 500 rows, so a first run over a large archive does not hold one long transaction; reclaiming the disk space of the emptied values is left to autovacuum.

Audit logging ​

Every authenticated external API request is written to the operator log as a structured JSON line with the key external_api_request. The log entry includes:

FieldDescription
tenantTenant name from the authenticated JWT
namespaceTenant target namespace
methodHTTP method
pathRequest path
statusHTTP response status code
latency_msRequest processing time in milliseconds

Example log line:

json
{"time":"2024-01-01T12:00:00Z","level":"INFO","msg":"external_api_request","tenant":"acme","namespace":"tenant-acme","method":"POST","path":"/v1/tasks","status":201,"latency_ms":42}

Scraping with Prometheus ​

agent-orca ships a dedicated Service exposing the operator's controller-runtime metrics on port 8080 (<release>-metrics), plus Prometheus-format /metrics endpoints on the External Task API (8084) and the ACP API (8000). Use the server label to distinguish the API metrics.

You do not need a separate external service to collect these metrics — they are plain Prometheus/OpenMetrics HTTP endpoints. The only question is how a scraper discovers and reaches them. In-cluster Prometheus (via the Prometheus Operator) is the supported default; Datadog and any OpenMetrics consumer can scrape the same Service/Pod endpoints with no code changes.

Prometheus Operator (ServiceMonitor / PodMonitor) ​

When the monitoring.coreos.com CRDs are installed (the project's charts/cluster and cloudnative-pg charts already depend on them if they are enabled). The agent-orca Helm chart renders the following when metrics.serviceMonitor.enabled and metrics.modelRouter.podMonitor.enabled are both true:

  • a ServiceMonitor scraping the operator metrics Service (port 8080), and
  • a PodMonitor scraping every model-router sidecar on port 9091.

Toggle them in values.yaml under metrics.:

bash
helm upgrade agent-orca ./charts/agent-orca \
  --set metrics.serviceMonitor.enabled=true \
  --set metrics.modelRouter.podMonitor.enabled=true
# or disable the whole metrics feature (Service + annotations + monitors):
#   --set metrics.enabled=false

Reaching agent-pod metrics behind the NetworkPolicy ​

The model-router PodMonitor scrapes agent pods by PodIP on :9091. Each AgentRun's NetworkPolicy is deny-by-default, so agent-orca opens :9091 only from namespaces labeled metrics: enabled — the same convention already used for the operator's own metrics port (8080). Label your scraper namespace:

bash
kubectl label namespace prometheus-operator metrics=enabled

In-flight spend in the cost dashboard ​

The operator scrapes the model-router's :9091 itself to show spend for runs that have not finished (inFlightUSD in GET /api/costs). A running run's status.spendUSD stays empty until the controller stamps it at a terminal state or retry, so the router's agentorca_modelrouter_spend_usd_total counter is the only live source.

  • Only unfinished runs are read, one request per run's (router) pod, in parallel with a 3s overall budget and at most 50 pods per request. Finished runs use their stamped status, so a warm pod that still holds an old run's series is not counted twice.
  • Every per-run NetworkPolicy therefore also admits the operator's own pods on :9091 (namespace POD_NAMESPACE, pods labeled app.kubernetes.io/name: agent-orca and app.kubernetes.io/component: operator), in addition to metrics: enabled namespaces. No other pod in the operator's namespace and no other port is opened.
  • When a run's router cannot be read (pod not scheduled yet, scrape timeout, policy mismatch), the response reports it in inFlightUnscraped instead of treating the run as $0.

To check that a cluster's policies let the operator reach a router, run hack/verify-router-metrics.sh <namespace> [pod].

Datadog / external scrapers ​

Point a Datadog OpenMetrics integration at the same targets:

  • Operator metrics: http://<release>-metrics.<namespace>.svc:8080/metrics
  • model-router metrics: discover pods with the metrics container port (9091) via the Datadog Kubernetes/Agent integration, or set a pod-level prometheus.io/scrape: "true" check.

The prometheus.io/scrape, prometheus.io/port, and prometheus.io/path annotations are added to the operator pod by default (metrics.enabled=true), so Datadog auto-discovery works without a ServiceMonitor.

Static scrape config (plain Prometheus, no Operator) ​

yaml
scrape_configs:
  - job_name: "agent-orca-operator"
    static_configs:
      - targets: ["<release>-metrics.<namespace>.svc:8080"]
    metrics_path: /metrics
  - job_name: "agent-orca-external"
    static_configs:
      - targets: ["<release>-internal-api.<namespace>.svc:8084"]
    metrics_path: /metrics

Both the External Task API (8084) and ACP API (8000) expose metrics on the same path. Use the server label to distinguish them.

Released under the Apache 2.0 License.