Skip to content

ollama_log_stats

Log stats (measured economics). OPS. Aggregate the NDJSON receipts into measured economics — no model call, no egress, instant. Optional since (ISO-8601) bounds the window (‘tokens this week’). Returns {totals:{calls, tokens_in, tokens_out}, by_tool:{calls, tokens, cloud_calls, degraded_calls, p50/p95 elapsed_ms}, by_tier, backend:{cloud_calls, local_calls, degraded_calls, unrouted_calls, backend_fallback_events, fallback_rate}, tier_events:{timeouts, fallbacks}, elapsed_ms:{p50, p95}, events_scanned, log_path, log_present}. fallback_rate = degraded/(cloud-intended) — the early-warning that cloud is degrading; null when nothing intended cloud. Answers ‘cloud vs local split’, ‘fallback rate’, ‘p95 per tool’ without jq. Empty/absent log → zeros, never an error. Use ollama_log_tail for the raw events behind any number here.

Parameter Type Required Default Description
since string no ISO-8601 timestamp. Aggregate only events with ts >= since (e.g. ‘tokens this week’). Invalid ISO → SCHEMA_INVALID. Omit for the whole log.

The JSON Schema below is generated from the same zod schema the server validates against at the wire — it cannot drift from runtime behavior.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"since": {
"description": "ISO-8601 timestamp. Aggregate only events with ts >= since (e.g. 'tokens this week'). Invalid ISO → SCHEMA_INVALID. Omit for the whole log.",
"type": "string"
}
}
}

Every tool returns the standard envelope — tier_used, model, tokens_in/tokens_out, elapsed_ms, backend provenance, warnings. See Envelope & tiers.

Schema + handler: src/tools/logStats.ts · registration: src/index.ts


Back to the Tool Reference.