Files
VoxPopuli/METRICS_API_EXAMPLES.md
2026-05-04 22:07:30 -06:00

1.6 KiB

Metrics API Examples

Record Metric (Manual)

curl -X POST "http://localhost:8004/metrics/record" \
  -H "Content-Type: application/json" \
  -d '{
    "event_type": "user_created",
    "entity_id": "123",
    "entity_type": "user",
    "user_id": 456,
    "metadata": {"email": "user@example.com"}
  }'

Get Analytics Report (Last N Days)

curl "http://localhost:8004/metrics/report?days=7"

Response:

{
  "start_date": "2026-04-27T00:00:00",
  "end_date": "2026-05-04T23:59:59",
  "total_events": 245,
  "events_by_type": {
    "user_created": 12,
    "report_created": 45,
    "notification_sent": 188
  }
}

Get Daily Statistics

curl "http://localhost:8004/metrics/daily-stats?date=2026-05-04T00:00:00"

Response:

[
  {
    "date": "2026-05-04T00:00:00",
    "event_type": "user_created",
    "count": 3
  },
  {
    "date": "2026-05-04T00:00:00",
    "event_type": "report_created",
    "count": 8
  }
]

Get Event Summary (Date Range)

curl "http://localhost:8004/metrics/summary?start_date=2026-04-27T00:00:00&end_date=2026-05-04T23:59:59"

Response:

{
  "summary": {
    "user_created": 12,
    "report_created": 45,
    "notification_sent": 188,
    "moderation_completed": 5
  },
  "date_range": {
    "start_date": "2026-04-27T00:00:00",
    "end_date": "2026-05-04T23:59:59"
  }
}

Health Check

curl "http://localhost:8004/metrics/health"

Automatic Events (RabbitMQ)

  • user_created, user_updated, user_deleted
  • report_created, report_resolved
  • notification_sent
  • moderation_completed