Skip to content

Implement connection metrics collection and analytics #39

@parfenovvs

Description

@parfenovvs

Summary

Add comprehensive metrics collection for VPN connections to enable performance monitoring, usage analytics, and optimization insights.

Features

Metrics Collection

  • Connection duration and frequency
  • Bandwidth usage (upload/download)
  • Server performance metrics (latency, throughput)
  • Connection success/failure rates
  • Geographic usage patterns
  • Protocol-specific metrics

Privacy-Respecting Analytics

  • Local data storage with optional cloud sync
  • Anonymized/aggregated data only
  • User consent and opt-out mechanisms
  • No personally identifiable information (PII)

Metrics Commands

# View connection statistics
mbvpn metrics show

# Export metrics data
mbvpn metrics export --format json --period 30d

# Configure metrics collection
mbvpn metrics config --enable-collection
mbvpn metrics config --disable-upload

Example Output

Connection Metrics (Last 30 days):
┌─────────────────────┬─────────────┬─────────────┐
│ Metric              │ Value       │ Trend       │
├─────────────────────┼─────────────┼─────────────┤
│ 📊 Total Sessions   │ 127         │ ↗️ +15%     │
│ ⏱️ Avg Duration     │ 4h 23m      │ ↗️ +8%      │
│ 📈 Data Transfer    │ 45.2 GB     │ ↗️ +22%     │
│ 🎯 Success Rate     │ 98.4%       │ ↗️ +2%      │
│ 🌍 Top Server       │ us-east-01  │ 34 sessions │
│ ⚡ Avg Latency      │ 28ms        │ ↘️ -5ms     │
└─────────────────────┴─────────────┴─────────────┘

Most Used Servers:
1. us-east-01 (New York)     34 sessions, 24h avg
2. us-west-02 (Los Angeles)  28 sessions, 18h avg
3. eu-central-01 (Frankfurt) 22 sessions, 12h avg

Data Storage Format

{
  "metrics": {
    "daily": [
      {
        "date": "2025-01-15",
        "sessions": 5,
        "duration_total": 18420,
        "bytes_up": 1048576,
        "bytes_down": 52428800,
        "servers": {
          "us-east-01": {"count": 3, "avg_latency": 25},
          "us-west-02": {"count": 2, "avg_latency": 45}
        }
      }
    ]
  }
}

Implementation Details

  • Store metrics in ~/.config/mbvpn/metrics.json
  • Collect metrics during connection lifecycle
  • Aggregate data daily/weekly/monthly
  • Implement data retention policies
  • Add configuration for metric collection preferences

Privacy Controls

# In ~/.config/mbvpn/config.yml
metrics:
  collection_enabled: true
  cloud_sync_enabled: false  # User must explicitly enable
  retention_days: 90
  anonymize_data: true

Priority

📊 Priority 3 (3-4 weeks)

Labels

  • enhancement
  • priority-3
  • monitoring
  • analytics
  • privacy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions