38 lines
980 B
Python
38 lines
980 B
Python
"""
|
|
Views for monitoring and metrics.
|
|
"""
|
|
from rest_framework.decorators import api_view, permission_classes
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from rest_framework.response import Response
|
|
from django.db.models import Count
|
|
from apps.core.models import APIUsage
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
@api_view(['GET'])
|
|
@permission_classes([IsAuthenticated])
|
|
def metrics(request):
|
|
"""Get system metrics."""
|
|
# This would be implemented with actual metrics collection
|
|
return Response({
|
|
'api_calls_today': 0,
|
|
'active_users': 0,
|
|
'system_status': 'healthy',
|
|
})
|
|
|
|
|
|
@api_view(['GET'])
|
|
@permission_classes([IsAuthenticated])
|
|
def health_check(request):
|
|
"""Detailed health check."""
|
|
return Response({
|
|
'status': 'healthy',
|
|
'timestamp': datetime.now().isoformat(),
|
|
'services': {
|
|
'database': 'healthy',
|
|
'redis': 'healthy',
|
|
'celery': 'healthy',
|
|
}
|
|
})
|
|
|