Skip to content

Latest commit

Β 

History

History
411 lines (320 loc) Β· 8.2 KB

MONITORING_EXAMPLES_API.md

File metadata and controls

411 lines (320 loc) Β· 8.2 KB

🎨 Monitoring Examples API & UI

Generate realistic monitoring data through APIs or UI with custom parameters.


πŸš€ Quick Access

UI (Easiest)

http://localhost:3000/monitoring/examples

Features:

  • βœ… Click-to-generate data
  • βœ… 5 predefined scenarios
  • βœ… Custom parameter controls
  • βœ… Real-time preview
  • βœ… One-click clear all data
  • βœ… Visual results dashboard

API (Programmatic)

POST /api/v1/monitoring/examples/generate
DELETE /api/v1/monitoring/examples/clear

πŸ“– Using the UI

Step 1: Navigate to Examples

From monitoring sidebar β†’ Click "Examples" (with "New" badge)

Or go directly: http://localhost:3000/monitoring/examples

Step 2: Choose a Scenario

5 Predefined Scenarios:

  1. Healthy System 🟒

    • 95% success rate
    • 120ms average latency
    • 5% alert rate
    • Perfect for demos
  2. Degraded Performance 🟑

    • 75% success rate
    • 800ms average latency
    • 25% alert rate
    • Shows mixed conditions
  3. Critical Issues πŸ”΄

    • 30% success rate
    • 1500ms average latency
    • 70% alert rate
    • Worst-case scenario
  4. Varied Conditions πŸ”΅

    • 70% success rate
    • 500ms average latency
    • 30% alert rate
    • Default/balanced
  5. Custom Configuration 🟣

    • Fully customizable
    • Control every parameter
    • Advanced use cases

Step 3: Configure Data Volume

Use sliders to set:

  • Number of Monitors: 1-10
  • Number of Channels: 1-5
  • Runs per Monitor: 10-100

Example:

  • 5 monitors
  • 40 runs each
  • = 200 total runs

Step 4: (Optional) Custom Parameters

If you selected "Custom Configuration":

  • Success Rate: 0-100%
  • Average Latency: 50-2000ms
  • Alert Rate: 0-100%

Step 5: Generate Data

Click "Generate Data" button

Wait time: 2-10 seconds depending on volume

You'll see:

βœ… Example data generated successfully!

Scenario: Varied Conditions
Monitors Created: 5
Channels Created: 5
Runs Generated: 200
Alerts Created: 42

Success Rate: 68.5%
Avg Latency: 512ms
Active Alerts: 15

Step 6: View Generated Data

Click quick links:

  • View Runs β†’ /monitoring/runs
  • View Alerts β†’ /monitoring/alerts
  • View Channels β†’ /monitoring/channels

Step 7: (Optional) Clear All Data

Click πŸ—‘οΈ trash button β†’ Confirm β†’ All data deleted


πŸ”Œ Using the API

1. Generate Example Data

Endpoint: POST /api/v1/monitoring/examples/generate

Request Body:

{
  "workspace_id": "69ea929e916c52ac2ca53ab5",
  "scenario": "varied",
  "config": {
    "num_monitors": 5,
    "num_channels": 5,
    "num_runs_per_monitor": 40
  }
}

Scenarios:

  • "healthy" - 95% success
  • "degraded" - 75% success
  • "critical" - 30% success
  • "varied" - 70% success (default)
  • "custom" - Use custom parameters

Custom Configuration (scenario = "custom"):

{
  "workspace_id": "69ea929e916c52ac2ca53ab5",
  "scenario": "custom",
  "config": {
    "num_monitors": 3,
    "num_channels": 3,
    "num_runs_per_monitor": 50,
    "success_rate": 0.85,
    "avg_latency": 300,
    "alert_rate": 0.15
  }
}

Response (200):

{
  "success": true,
  "message": "Example data generated successfully",
  "summary": {
    "scenario": "Varied Conditions",
    "channels": 5,
    "monitors": 5,
    "runs": 200,
    "alerts": 42,
    "stats": {
      "success_rate": "68.5%",
      "avg_latency": "512ms",
      "active_alerts": 15
    }
  }
}

cURL Example:

curl -X POST http://localhost:3000/api/v1/monitoring/examples/generate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-token>" \
  -d '{
    "workspace_id": "69ea929e916c52ac2ca53ab5",
    "scenario": "healthy",
    "config": {
      "num_monitors": 5,
      "num_channels": 5,
      "num_runs_per_monitor": 40
    }
  }'

2. Clear All Monitoring Data

Endpoint: DELETE /api/v1/monitoring/examples/clear?workspace_id={id}

Query Parameters:

  • workspace_id (required): Your workspace ID

Response (200):

{
  "success": true,
  "message": "All monitoring data cleared successfully",
  "deleted": {
    "monitors": 5,
    "runs": 200,
    "alerts": 42,
    "channels": 5
  }
}

cURL Example:

curl -X DELETE \
  "http://localhost:3000/api/v1/monitoring/examples/clear?workspace_id=69ea929e916c52ac2ca53ab5" \
  -H "Authorization: Bearer <your-token>"

πŸ“Š What Gets Generated

Monitors (1-10)

  • Names: "API Health Check", "Authentication Service", etc.
  • Types: All HTTP
  • Status: Active
  • Schedule: Various cron intervals
  • Regions: us-east-1, us-west-2, eu-west-1
  • Tags: production, critical, auth, etc.
  • Assertions: Status code + latency checks

Notification Channels (1-5)

  • Slack - Production Alerts
  • Email - DevOps Team
  • PagerDuty - Critical Incidents
  • Microsoft Teams - Engineering
  • Webhook - Custom integration

All have example configurations.

Monitor Runs (10-1000)

  • Distributed across monitors
  • Realistic timing data
  • HTTP request/response details
  • Waterfall metrics (DNS, TCP, TLS, TTFB)
  • Assertion results (pass/fail)
  • Varied statuses based on scenario

Alerts (varies)

  • Based on failed runs
  • Different severities (critical, high, medium, low)
  • Random status (active, acknowledged, resolved)
  • Linked to notification channels
  • Realistic trigger times

🎯 Use Cases

1. Demo/Presentation

Scenario: Healthy
Monitors: 5
Runs per Monitor: 20
Total: 100 runs, ~5 failures, ~2 alerts

Shows a well-functioning system.

2. Testing Alert Workflows

Scenario: Critical
Monitors: 3
Runs per Monitor: 30
Total: 90 runs, ~60 failures, ~40 alerts

Lots of alerts to test acknowledge/resolve features.

3. Performance Testing UI

Scenario: Varied
Monitors: 10
Runs per Monitor: 100
Total: 1000 runs, ~300 failures, ~90 alerts

Stress test the UI with large datasets.

4. Custom Simulation

Scenario: Custom
Success Rate: 85%
Latency: 250ms
Alert Rate: 10%

Match your specific requirements.


πŸ’‘ Tips

For Demos

  • Use "Healthy" scenario
  • 5 monitors, 20 runs each
  • Clean, professional data
  • Few alerts to manage

For Testing

  • Use "Varied" scenario
  • 5-10 monitors
  • 40-50 runs each
  • Good mix of conditions

For Development

  • Start with "Varied"
  • Generate data once
  • Test features thoroughly
  • Clear when done

For Load Testing

  • Use "Custom" scenario
  • 10 monitors
  • 100 runs each
  • Test pagination, performance

⚠️ Important Notes

Data Persistence

  • βœ… Generated data persists in MongoDB
  • βœ… Survives server restarts
  • βœ… Accumulates with multiple generations
  • ❌ Must manually clear to remove

Workspace Isolation

  • βœ… Data is workspace-specific
  • βœ… Each workspace has separate data
  • βœ… Clearing only affects current workspace

Resource Usage

  • Generating 1000 runs takes ~5-10 seconds
  • Database size: ~1-5 MB per 1000 runs
  • TTL cleanup: 90 days automatic

Limitations

  • Max 10 monitors per generation
  • Max 5 channels per generation
  • Max 100 runs per monitor per generation
  • Can generate multiple times to accumulate more

πŸ”§ Troubleshooting

"workspace_id is required"

β†’ Select a workspace first (top navbar)

Generation takes too long

β†’ Reduce number of runs (try 20 instead of 100)

UI not showing data

β†’ Refresh the page or click "View Runs" button

Clear doesn't work

β†’ Confirm the dialog prompt β†’ Check workspace is selected

API returns 401

β†’ Check authentication token β†’ Login again to refresh token


πŸ“š Related Documentation

  • API Examples: MONITORING_API_EXAMPLES.md
  • Integration Guide: MONITORING_END_TO_END_GUIDE.md
  • Quick Start: INTEGRATION_SUMMARY.md

πŸŽ‰ Quick Start

Fastest way to test the monitoring system:

  1. Open http://localhost:3000/monitoring/examples
  2. Keep default settings (Varied, 5 monitors, 40 runs)
  3. Click "Generate Data"
  4. Wait 5 seconds
  5. Click "View Runs"
  6. Explore the monitoring system!

Done! You now have 200 realistic runs to test with.


Last Updated: April 25, 2026
Version: 1.0.0