@dustinober/glm-monitor
v1.0.1
Published
Professional dashboard for monitoring GLM Coding Plan API usage
Maintainers
Readme
@dustinober/glm-monitor
A professional dashboard for monitoring your GLM Coding Plan API usage and quotas. Track tokens, model calls, MCP tool usage, and quota limits in real-time.

Features
- 📊 Real-time metrics - Tokens, model calls, and MCP tool usage
- 📈 Historical charts - 24-hour data retention with auto-refresh
- ⚠️ Quota alerts - Visual warnings when approaching limits
- 🔄 Auto-refresh - Dashboard updates every 30 seconds
- 💾 Persistent storage - Data survives restarts
- 📤 Export - Download data as CSV
Installation
Option 1: Global Install (Recommended)
npm install -g @dustinober/glm-monitorThis installs the glm-monitor CLI tool globally, available from anywhere.
Option 2: Project Install
git clone <repo-url>
cd glm-monitor
npm installQuick Start
1. Initialize Configuration
# If globally installed
glm-monitor init
# Or if using project directly
npx @dustinober/glm-monitor initYou can also set your token explicitly:
glm-monitor init -t "YOUR_AUTH_TOKEN_HERE"2. Open Dashboard
# Automatically collects data, then opens dashboard
npm start
# Or using the CLI:
glm-monitor startThe dashboard opens at http://localhost:8080 (or http://localhost:5173 in dev mode).
Data Collection:
npm start/glm-monitor start: Collects fresh data before opening.npm run monitor: Collects data and opens dashboard.- Use
--no-collectto skip collection:glm-monitor start --no-collect
Dashboard Interface Guide
The dashboard provides a comprehensive view of your usage:
1. Usage Overview Cards
Located at the top, these cards show your aggregate usage:
- Compute Tokens: Total tokens consumed with trend indicator.
- API Manifestations: Total number of model calls.
- MCP Tool Navigations: Count of tool invocations (e.g., search, web-reader).
2. Quota Status
Color-coded indicators show your current standing against limits:
- Neural Token Capacity (5-hour rolling):
- 🟢 Green (<50%): Healthy usage.
- 🟡 Yellow (50-80%): Approaching limit.
- 🔴 Red (>80%): Critical usage.
- Temporal Access Quota (monthly): Monitor your long-term consumption.
3. Usage Trend Chart
The central chart visualizes usage over the last 24 hours:
- Left Axis (Bars): Token usage in millions.
- Right Axis (Line): Model calls.
- Data Points: Hover over any bar to see precise timestamped data.
- Auto-Update: The chart refreshes automatically every 30 seconds.
Automation
Set up automatic data collection to keep your history complete without manual intervention.
macOS (launchd)
Create ~/Library/LaunchAgents/com.user.usage-monitor.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.usage-monitor</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/npm</string>
<string>run</string>
<string>collect</string>
</array>
<key>WorkingDirectory</key>
<string>/path/to/GLM_Dashboard</string>
<key>StartInterval</key>
<integer>300</integer>
</dict>
</plist>Load with:
launchctl load ~/Library/LaunchAgents/com.user.usage-monitor.plistLinux (cron)
Open crontab:
crontab -eAdd the following line to run every 5 minutes:
*/5 * * * * cd /path/to/GLM_Dashboard && npm run collectData Storage & Configuration
Data Locations
| Location | Purpose |
|----------|---------|
| ~/.glm-monitor/usage-history.json | Persistent data storage (24h retention) |
| ~/.glm-monitor/config.json | Auth token and API settings |
Environment Variables
You can override configuration using environment variables:
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-token-here"API Endpoints
The collector queries these GLM Monitoring API endpoints:
| Endpoint | Purpose |
|----------|---------|
| /api/monitor/usage/model-usage | Token and call statistics |
| /api/monitor/usage/tool-usage | MCP tool invocation counts |
| /api/monitor/usage/quota/limit | Current quota limits and usage |
Troubleshooting
"token expired or incorrect"
Your auth token has expired. Re-initialize:
glm-monitor init -t "YOUR_NEW_TOKEN"No data showing in dashboard
- Run
npm run collectto fetch initial data. - Verify
~/.glm-monitor/usage-history.jsonexists. - Check browser console for errors.
Charts not updating
- Click the "Sync Now" button to manually refresh.
- Dashboard auto-refreshes every 30 seconds.
- Verify data file is being updated:
ls -la ~/.glm-monitor/
License
MIT
