Commit graph

10 commits

Author SHA1 Message Date
Johannes Millan
78f64508db feat(sync-server): add active-users-quick monitor command
Avoids the operations table entirely (sync_devices + users only) so it
returns in milliseconds even when operations grows past 1 GB. Useful when
the standard active-users command is too slow on large prod DBs.
2026-04-21 15:03:42 +02:00
Johannes Millan
62f9f9cfd4 fix(sync-server): avoid per-user correlated scans in monitor usage
The showUsage query ran two correlated subqueries over the full
operations table once per user, each calling pg_column_size(payload)
on every row, then sorted all users before LIMIT 20. On a 1.85 GB
operations table with 3.6k users this effectively never returned.

Aggregate per-user size and count in a single CTE pass, then join.
One sequential scan instead of scans × users.
2026-04-20 18:51:12 +02:00
Johannes Millan
2d7656c5c8 fix(monitoring): mask PII, add types, fix sort and validation issues
Mask user emails by default (--unmask to reveal). Replace all any[]
query results with typed interfaces. Fix showUsageHistory sort that
compared formatted byte strings. Add parseIntArg validation for CLI
flags. Fix unbounded recursion in analyzePayload. Replace execSync with
execFileSync for DATA_DIR to prevent shell injection. Add --no-save flag
for usage command.
2026-03-23 10:52:57 +01:00
Johannes Millan
fe65d81635
Add active users monitoring command with engagement metrics (#6921)
* feat(sync): add active-users command to monitor CLI

Adds a new `active-users` command to the SuperSync monitor script that reports:
- Total registered and verified user counts
- Active users by time period (24h, 7d, 30d, 90d) based on device and sync activity
- New registration counts
- Recently active users table with device count and ops
- Users who never synced

Usage: npm run monitor -- active-users

https://claude.ai/code/session_014Tc5vtXW4Z8QZFMDFWKErP

* feat(sync): add engaged users metric to active-users report

Shows users who were active on 3+ distinct days in the last 2 weeks
with new sync operations, giving a measure of genuine recurring usage.

https://claude.ai/code/session_014Tc5vtXW4Z8QZFMDFWKErP

* docs(sync): add active-users to docker monitoring docs

Add missing active-users command to docker-monitor.sh case statement,
help text, and DOCKER-MONITORING.md guide.

https://claude.ai/code/session_014Tc5vtXW4Z8QZFMDFWKErP

* refactor(sync): improve active-users command from review feedback

- Fix timezone-unsafe DATE(): use AT TIME ZONE 'UTC' with explicit
  double precision cast for consistent day boundaries
- Replace correlated subquery with LEFT JOIN for ops_7d count
- Show total active count when LIMIT truncates the table
- Add --threshold and --limit CLI flags for flexibility
- Combine device/ops metrics into single line (connected / syncing)
- Add skipInQuick to run-all-monitoring.ts
- Update docker-monitor.sh header, help text, and DOCKER-MONITORING.md
  with active-users command, flags, and performance notes
- Clarify "never synced" output label

https://claude.ai/code/session_014Tc5vtXW4Z8QZFMDFWKErP

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-22 23:15:14 +01:00
Johannes Millan
78d4e4245a feat(sync-server): add operation analysis to monitor CLI
- Add 'ops' command to analyze operation payload sizes
- Show breakdown by entity type with count, total, avg, max sizes
- Display largest operation with payload structure analysis
- Enhance 'usage' command to show ops vs snapshot breakdown
- Show operation count, average size per user
2025-12-19 16:23:52 +01:00
Johannes Millan
90a8190cb8 refactor(sync-server): change usage-history to pivot table format
Shows users as rows with snapshot dates as columns for easier
comparison across time.
2025-12-19 16:19:49 +01:00
Johannes Millan
5917e0d052 feat(sync-server): add per-user growth table to usage-history
Shows each user's storage change between first and last snapshot,
sorted by growth (highest first).
2025-12-19 16:16:57 +01:00
Johannes Millan
a42f0025cb feat(sync-server): add usage history tracking
Each run of `npm run monitor -- usage` now saves a snapshot to
logs/usage-history.jsonl. New command `usage-history` shows past
snapshots with growth stats between runs.
2025-12-19 16:15:38 +01:00
Johannes Millan
754f7fb676 feat(sync-server): add disk space and table size monitoring
- Add disk space info to monitor stats (root filesystem, data dir)
- Add top 5 tables by size to database stats
- Add GHCR login to deploy.sh for private image pulls
2025-12-19 15:54:09 +01:00
Johannes Millan
2c42cf65cb feat(super-sync-server): Add basic monitoring tool
This commit introduces a lightweight monitoring CLI tool for the super-sync-server.

Changes include:
- Enhanced logging:  now supports writing logs to a file () when  is set, enabling persistent log storage.
- New monitoring script:  provides commands for:
    - : Displays system vitals (CPU, RAM) and database connectivity/size.
    - : Shows top 20 users by data storage usage within the database.
    - : Allows tailing, searching, and filtering server logs from the file.
-  update: Added a  script to easily run the tool.
2025-12-12 20:48:40 +01:00