Skip to main content

Usage Monitoring

🟠 Alpha

The nanx monitor command provides insights into your nanx usage, including AI token consumption, command frequency, and cost tracking.

Quick Start

# Show usage dashboard
nanx monitor

# Show specific timeframe
nanx monitor --period week

# Show only AI usage
nanx monitor ai

What Gets Tracked

AI Usage Metrics

  • Token Usage: Input and output tokens per provider/model
  • API Calls: Number of requests to each AI provider
  • Estimated Costs: Based on provider pricing
  • Models Used: Which models were invoked
  • Success Rate: Failed vs successful API calls

Command Usage Metrics

  • Frequency: Most-used commands and shortcuts
  • Execution Time: Average time per command
  • Error Rate: Failed vs successful executions
  • Patterns: Common command sequences

Repository Activity

  • Commits: Number of commits (AI-generated vs manual)
  • Branches: Branches created/switched
  • Releases: Releases created
  • File Changes: Files modified over time

Subcommands

Dashboard (Default)

Show overall usage dashboard:

nanx monitor

The dashboard displays:

  • Summary cards (total commands, AI calls, costs)
  • Charts for usage over time
  • Top commands and shortcuts
  • Recent activity log

ai

Show detailed AI usage statistics:

nanx monitor ai

Displays:

AI Usage Summary (Last 30 days)
─────────────────────────────────
Total Requests: 142
Total Tokens:   1,245,832
  Input:        823,456
  Output:       422,376
Estimated Cost: $4.23

By Provider:
  Anthropic (Claude)
    Requests:  98
    Tokens:    892,341
    Cost:      $3.12

  OpenAI (GPT-4)
    Requests:  44
    Tokens:    353,491
    Cost:      $1.11

By Model:
  claude-3-5-sonnet-20241022: 78 requests
  gpt-4-turbo:                44 requests

commands

Show command usage statistics:

nanx monitor commands

Example output:

Command Usage (Last 30 days)
─────────────────────────────────
Total Commands: 1,847

Top Commands:
  1. repo status (r s)      456 times
  2. repo commit (r c)      234 times
  3. config show            89 times
  4. apps list              67 times
  5. sys top                45 times

Avg Execution Time: 0.34s
Success Rate:       98.2%

export

Export usage data for external analysis:

# Export to JSON
nanx monitor export --format json > usage.json

# Export to CSV
nanx monitor export --format csv > usage.csv

# Export specific period
nanx monitor export --period month --format json

Command Options

Option Description Default
--period <time> Time period: day, week, month, year, all month
--format <fmt> Output format: table, json, csv table
--provider <name> Filter by AI provider all
--project <path> Filter by project path all

Examples

Check AI Costs

# This month's AI usage
nanx monitor ai --period month

# Last 7 days
nanx monitor ai --period week

# Specific provider
nanx monitor ai --provider anthropic

Analyze Command Usage

# Most-used commands
nanx monitor commands

# Today's activity
nanx monitor commands --period day

# Export for analysis
nanx monitor commands --format json > commands.json

Project-Specific Stats

# Usage for current project
nanx monitor --project .

# Compare across projects
nanx monitor ai --format json | jq '.by_project'

Privacy & Data Storage

What's Collected

Nanx stores locally:

  • Command names and timestamps
  • AI provider/model names and token counts
  • Repository paths (hashed for privacy)
  • Success/failure status

What's NOT Collected

  • Actual file contents or code
  • Commit messages or code diffs
  • API keys or credentials
  • Personal information

Data Location

Usage data is stored locally at:

~/.local/share/nanx/usage.db

Disable Tracking

To disable usage tracking:

# In your config.yaml
monitor:
  enabled: false

Clear History

# Delete all usage data
rm ~/.local/share/nanx/usage.db

# Or clear specific period
nanx monitor clear --period month

Cost Estimation

Cost estimates are based on official provider pricing as of the last nanx update. Actual costs may vary based on:

  • Provider pricing changes
  • Volume discounts
  • Special pricing agreements
  • Network/API overhead

Current Pricing Reference

Provider Model Input (per 1M tokens) Output (per 1M tokens)
Anthropic Claude 3.5 Sonnet $3.00 $15.00
OpenAI GPT-4 Turbo $10.00 $30.00
OpenAI GPT-3.5 Turbo $0.50 $1.50
Google Gemini Pro $0.50 $1.50

Note: Prices shown are estimates and may not reflect current rates.

Troubleshooting

No Data Showing

If the monitor shows no data:

# Check if tracking is enabled
nanx config show monitor

# Verify database exists
ls -la ~/.local/share/nanx/usage.db

# Enable tracking if disabled
monitor:
  enabled: true

Incorrect Cost Estimates

If costs seem off:

# Export raw data for verification
nanx monitor export --format json > usage.json

# Check provider pricing updates
# Pricing is updated with each nanx release

Next Steps