cogno-observability
SRE/Ops monitoring for the Cogno stack — a Prometheus metrics sink + /metrics wiring + Grafana dashboards/alerts, plus a one-login deploy stack for metrics and live logs.
Where cogno-anima is the mind and cogno-homeo keeps the calls alive, cogno-observability is the operator's eyes on the running fleet — how many turns, how fast, how much they cost, where they fail. It attaches to the host from outside its cognition, so the host never imports prometheus_client.
Status: alpha — metrics sink +
/metricswiring + deploy stack + unit/contract suite in place.
SRE/Ops monitoring is the operator-facing pillar — cross-tenant fleet health — and is deliberately separate from two other consumers of the same turn data:
| Surface | Audience | This repo? |
|---|---|---|
| Fleet monitoring (Prometheus/Grafana, cross-tenant) | operator / SRE | ✅ yes |
Radar Tokens (per-tenant usage, from the token_ledger) |
the tenant/customer | ❌ cogno-ui |
| Billing / BudgetGuard (quota, spend) | the platform | ❌ cogno-host + cogno-meter |
Why a separate repo
The house rule is libs emit, host configures — and the host stays prometheus-agnostic. It
emits one TurnEvent per turn to an injected MetricsSink and exposes an instrument(app) hook;
it never imports prometheus_client. This package fills both seams, so the Prometheus dependency,
the metric catalog, and the dashboards live here — swappable, versioned independently, and absent
from a deployment that doesn't want them.
Logs ≠ metrics
Two different pipelines. Logs (host configure_logging → stdout → Loki/ELK) answer "what
happened in this turn?" and may carry high-cardinality tenant/identity/session. Metrics
(this repo) answer "how is the fleet doing?" — aggregate series with low-cardinality labels
only. session_id/identity_id are never Prometheus labels (they'd blow up the TSDB); use
logs for per-turn tracing. tenant is opt-in and capped (PrometheusMetricsSink(tenant_label=True)).
Install
pip install cogno-observability # core (prometheus-client)
pip install "cogno-observability[http]" # + per-route HTTP RED metrics (fastapi instrumentator)
Wire it into the host
from cogno_host.api.pg_app import create_pg_app
from cogno_observability import PrometheusMetricsSink, attach
app = create_pg_app(
dsn, auth=admin,
metrics_sink=PrometheusMetricsSink(), # per-turn TurnEvent → Prometheus series
instrument=attach, # mounts /metrics + HTTP instrumentation
)
With neither argument the host runs exactly as before (no-op sink, no /metrics).
Metrics
| Metric | Type | Labels | Meaning |
|---|---|---|---|
cogno_turns_total |
counter | route, stop_reason, ok, blocked, cache_hit | turn outcomes |
cogno_turn_errors_total |
counter | error | unhandled exceptions (by class) |
cogno_turn_duration_seconds |
histogram | route | end-to-end latency |
cogno_stage_duration_seconds |
histogram | stage | per cognitive-stage latency |
cogno_stage_tokens_total |
counter | stage, model, direction | tokens (in/out/embedding) |
cogno_cost_usd_total |
counter | — | provider spend (0 for local) |
cogno_drift_score |
histogram | — | cumulative drift distribution |
cogno_drift_actions_total |
counter | action | drift-triggered actions |
cogno_tool_calls_total / _failures_total |
counter | — | EGO tool calls / failures |
cogno_failovers_total, cogno_self_corrections_total, cogno_handoffs_total |
counter | — | reliability |
cogno_blocked_total |
counter | stop_reason | safety/quota/PII blocks |
Plus HTTP RED metrics (http_request_*) from the instrumentator.
Multi-worker
Each uvicorn/gunicorn worker has its own registry. Set PROMETHEUS_MULTIPROC_DIR to a shared
(empty at boot) dir and attach will reconcile across workers via MultiProcessCollector at scrape
time. Without it, single-process mode is used.
Ops assets (ops/)
alerts/cogno_rules.yml— Prometheus recording + alerting rules.dashboards/cogno_overview.json— Grafana dashboard (import, pick your Prometheus datasource).dashboards/cogno_logs.json— Grafana dashboard for live logs (Loki).prometheus-scrape.example.yml— scrape config / ServiceMonitor example.SLOs.md— starting SLOs + a metric→runbook map.
Deploy — one Grafana login for metrics + logs
deploy/ is a docker-compose stack (Prometheus + Loki + Promtail + Grafana) that watches an
existing host and gives you one Grafana login to follow it live — metrics and near-real-time
logs on the same pane. See deploy/README.md.
Host integration
The host exposes two seams (metrics_sink= + instrument(app)) and stays prometheus-agnostic;
this library fills them. See docs/HOST_INTEGRATION.md.
The Cogno ecosystem
cogno-observability is one organ of Cogno — a family of
small, composable, Apache-2.0 libraries that together form a complete conversational-agent
platform. Each library owns a single concern and stays infra-agnostic; a host assembles them
into a running agent:
The open-source libraries are the organs; the host is the body that joins them. Our reference
host — cogno-host, with its cogno-ui dashboard — is the private product layer, but it holds no
special powers: everything it does rides on the public seams documented in each library's
docs/HOST_INTEGRATION.md.
Metadata
Release files for cogno-observability 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cogno_observability-0.1.0.tar.gz | 18.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cogno_observability-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.5 kB
Release files / cogno_observability-0.1.0.tar.gz
| Download URL | cogno_observability-0.1.0.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
218f8af7158a26b638ef94df92d8186611b3811eb9b5a9f44bf1fb214ad78ab8
|
|
BLAKE2b-256 checksum How to use checksums |
299be08c30d5fae9f2f8f2ba2f6f614ffcb5eac2a1de220c33754a075ad80aeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / cogno_observability-0.1.0-py3-none-any.whl
| Download URL | cogno_observability-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
106bd4d8b9d855cf77773195cba4b183ece02873edd343de6cf429b29c40d195
|
|
BLAKE2b-256 checksum How to use checksums |
944e50ba8a746db11b39be0a418bd25d7b238f48db39291c8770f6051529af3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for cogno-observability 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.