Skip to main content
NOV 2026 Latest guide updates. Latest: AI Design Patterns Local vs cloud AI Grill me Changelog →
M22 Advanced Methodology

Observability: JSONL & jq

Auditing and analyzing Claude Code activity through logs

PDF editions Β· Guide v3.44.1 Β· Updated

The JSONL registry: source of truth

Claude Code records conversation and tool activity in local JSONL transcripts stored in ~/.claude/projects/<project>/. They help reconstruct activity, but recorded tool requests are not proof that every requested effect completed. Correlate tool results and external logs.

Terminal window
# Locate session files for the current project
ls ~/.claude/projects/
# Select the actual project directory; do not guess its encoding
# β†’ SESSION_ID.jsonl SESSION_ID2.jsonl ...

Each assistant type line contains a content array whose tool_use entries document each tool call with its input parameters.

What tools expose

ToolAvailable information
ReadFile path, line range
Edit / WritePath, modified content
BashFull command executed
WebFetchRequested URL and processing prompt
AgentPrompt sent to sub-agent
Glob / GrepSearch patterns and scope

Essential jq queries

Terminal window
SESSION=~/.claude/projects/-my-project-/SESSION.jsonl
# Files read in the session
jq 'select(.type=="assistant") |
.message.content[]? |
select(.type=="tool_use" and .name=="Read") |
.input.file_path' "$SESSION"
# Bash commands executed
jq 'select(.type=="assistant") |
.message.content[]? |
select(.type=="tool_use" and .name=="Bash") |
.input.command' "$SESSION"
# Count by tool (activity profile)
jq -r 'select(.type=="assistant") |
.message.content[]? |
select(.type=="tool_use") | .name' \
"$SESSION" | sort | uniq -c | sort -rn

Sensitive patterns to monitor

These patterns are worth detecting automatically in audits:

PatternRiskjq filter
Read on .env, *.pem, id_rsaCredentials access`test(”\.(env
Bash with rm -rf or --force-pushDestructive actiontest("rm -rf")
WebFetch to external URLPotential exfiltrationselect .name=="WebFetch"
Write outside project directoryScope creepCompare path to current directory

For teams, export reviewed logs to access-controlled storage with an explicit retention policy. S3 versioning alone does not make logs immutable; that requires additional controls such as configured Object Lock.

Community external tools

ToolTypePrimary usage
ccusageCLI / TUICosts from JSONL, community reference
claude-code-otelOpenTelemetryExport to Prometheus + Grafana
ccboardTUI + WebSessions dashboard, costs, activity
AktoSaaSSecurity guardrails at API level
MLflow TracingCLI + SDKExact token counts, LLM evaluation
Terminal window
# Quick install
npm i -g ccusage # Costs and statistics
cargo install ccboard # Interactive dashboard
# Native OpenTelemetry configuration:
# https://code.claude.com/docs/en/monitoring-usage

Decision tree

Need costs quickly? β†’ ccusage (0 config)
Enterprise audit? β†’ claude-code-otel + Grafana
Already on MLflow? β†’ MLflow tracing integration
Visual dashboard? β†’ ccboard

Cost estimation in JSONL

JSONL logs do not contain Anthropic prices directly. Tools such as ccusage read recorded usage counters and apply model pricing to estimate cost. Missing records, pricing changes and subscription billing can make those estimates differ from the provider invoice.

Enter your email to read the full card and get the complete PDF bundle.

All content is free and open-source. We just ask for your email.

PDF: