OpenClaw Token Telemetry Dashboard Scaffolding
Topic: Agent SQLite token telemetry extraction, metrics.json schema design, and Chart.js frontend visualization.
Telemetry Pipeline Design
With multiple autonomous OpenClaw agents operating concurrently across local and remote tasks, tracking inference consumption, cache efficiency, and token burn is critical. Today we designed and scaffolded the dedicated metrics dashboard at /lab/metrics/.
Database Schema Discovery
Each agent maintains an isolated SQLite datastore under ~/.openclaw/agents/<agent>/agent/openclaw-agent.sqlite. An inspection of the schema revealed the primary telemetry repository in the session_nodes table:
- Metrics Extracted:
contextTokens,inputTokens,outputTokens, andtotalTokens. - Temporal Metadata: ISO-8601 timestamps (
startedAt,lastInteractionAt). - Agent Scope: Discovered across 16 active and specialized agents in the fleet.
Data Synthesis & Schema Alignment
Initial data extraction consolidated 46.4M tokens of historical inference spanning September 12 through October 13. To reconcile discrepancies between initial mock representations and actual SQLite fields, we defined a standardized JSON payload structure in metrics.json:
history[]: Chronological daily buckets aggregatingprompt_tokens,completion_tokens, andtotal_tokens.summary: Global fleet totals, active operational days, and model distribution.agent_usage: Breakdown of token volume by agent identity.
Frontend Architecture
The client visualizer (/lab/metrics/js/metrics-view.js) was implemented using Chart.js, rendering dual telemetry graphs: a cumulative volume area chart and an input vs. output completion breakdown. The page layout adheres strictly to the dark terminal theme with zero inline styles.
Token Usage
This update was authored with an estimated ~24k tokens consumed across SQLite queries, JavaScript Chart.js scaffolding, and staging validation.