{% extends "base.html" %} {% block title %}Cortex Metrics — ICDEV™{% endblock %} {% block content %}
CUI // SP-CTI

📊 Cortex Metrics

Governance, usage & spend over the append-only cortex_audit trail · last {{ stats.window_hours }}h · ← back to Cortex

{% for h in [1, 24, 168, 720] %} {{ '1h' if h==1 else ('24h' if h==24 else ('7d' if h==168 else '30d')) }} {% endfor %}
{% if not stats.available %}
No Cortex audit data yet — metrics populate as governed calls run. (The cortex_audit table may not exist on a fresh database until the first call.)
{% else %} {% set s = stats.summary %}
{% macro card(label, value, hint='') -%}
{{ label }}
{{ value }}
{% if hint %}
{{ hint }}
{% endif %}
{%- endmacro %} {{ card('Calls', s.calls) }} {{ card('Blocked', s.blocked, s.block_rate_pct ~ '% block rate') }} {{ card('Redactions', s.redactions, 'PII/CUI spans masked') }} {{ card('Cache hits', s.cache_hits) }} {{ card('Cost (USD)', '$%.4f'|format(s.cost_usd)) }} {{ card('Avg latency', s.avg_latency_ms ~ ' ms') }} {{ card('Tokens', '{:,}'.format(s.total_tokens), '{:,} in / {:,} out'.format(s.input_tokens, s.output_tokens)) }}

By function

{% for f in stats.by_function %} {% else %} {% endfor %}
FunctionCallsBlockedCost
{{ f.function }}{{ f.calls }}{{ f.blocked }}${{ '%.4f'|format(f.cost_usd) }}
no calls

By outcome

{% for outcome, n in stats.by_outcome.items() %} {% else %} {% endfor %}
{{ outcome }}{{ n }}
no data

By domain lens

{% for d in stats.by_domain %} {% else %} {% endfor %}
{{ d.domain }}{{ d.calls }}
no data

By tenant

{% for t in stats.by_tenant %} {% else %} {% endfor %}
TenantCallsBlocked
{{ t.tenant_id }}{{ t.calls }}{{ t.blocked }}
no data

By model

{% for m in stats.by_model %} {% else %} {% endfor %}
ModelCallsTokensCost
{{ m.model }}{{ m.calls }}{{ '{:,}'.format(m.total_tokens) }}${{ '%.4f'|format(m.cost_usd) }}
no data
{% endif %} {% endblock %}