HyperSaaS
BackendDeployment

Monitoring

Error tracking with Sentry and task monitoring with Flower.

Sentry

Sentry captures errors and exceptions across Django, Celery, and Redis.

Configuration

import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.redis import RedisIntegration

sentry_sdk.init(
    dsn=env("SENTRY_DSN"),
    integrations=[
        LoggingIntegration(
            level=logging.INFO,         # Breadcrumbs from INFO
            event_level=logging.ERROR,  # Events from ERROR
        ),
        DjangoIntegration(),
        CeleryIntegration(),
        RedisIntegration(),
    ],
    environment=env("SENTRY_ENVIRONMENT", default="production"),
    traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0),
)

Integrations

IntegrationWhat it captures
DjangoIntegrationUnhandled exceptions in views, middleware errors
CeleryIntegrationTask failures, retries, timeouts
RedisIntegrationRedis connection errors
LoggingIntegrationPython logging as breadcrumbs (INFO+) and events (ERROR+)

Performance Monitoring

Set SENTRY_TRACES_SAMPLE_RATE to enable transaction tracing:

SENTRY_TRACES_SAMPLE_RATE=0.1  # Sample 10% of requests

Leave at 0.0 in production unless actively debugging performance — tracing adds overhead.

Environment Variables

VariableDefaultDescription
SENTRY_DSNSentry project DSN
DJANGO_SENTRY_LOG_LEVELINFOMinimum log level for breadcrumbs
SENTRY_ENVIRONMENTproductionEnvironment tag
SENTRY_TRACES_SAMPLE_RATE0.0Transaction sample rate (0.0 - 1.0)

Flower

Flower provides a real-time web dashboard for Celery monitoring.

What it shows

  • Active, completed, and failed tasks
  • Worker status and resource usage
  • Task execution time and rate
  • Task details (arguments, result, traceback)
  • Broker (Redis) connection status

Access

EnvironmentURLAuth
Localhttp://localhost:5555None
Productionhttps://yourdomain.com:5555Basic auth

Production Auth

CELERY_FLOWER_USER=admin
CELERY_FLOWER_PASSWORD=your-secure-password

Flower is exposed via Traefik on a separate entrypoint (port 5555).

Logging

Django's logging is configured in base.py. Key loggers:

LoggerLevelPurpose
djangoINFODjango framework messages
django.requestERRORHTTP 4xx/5xx responses
backend.documents.tasksINFODocument ingestion pipeline
backend.chatINFOChat/agent operations
celeryINFOTask execution lifecycle

In production, Sentry captures all ERROR-level log entries as events and INFO-level entries as breadcrumbs for context.

Health Checks

Application

# Django system check
docker compose exec django python manage.py check

# Database connectivity
docker compose exec django python manage.py check --database default

# API responding
curl -s http://localhost:8000/api/schema/ | head -1

Celery

# Ping workers
docker compose exec django celery -A config.celery_app inspect ping

# Check active tasks
docker compose exec django celery -A config.celery_app inspect active

# Check scheduled tasks
docker compose exec django celery -A config.celery_app inspect scheduled

Database

# PostgreSQL shell
docker compose exec postgres psql -U $POSTGRES_USER -d $POSTGRES_DB

# Check pgvector extension
SELECT * FROM pg_extension WHERE extname = 'vector';

# Check table sizes
SELECT relname, pg_size_pretty(pg_total_relation_size(relid))
FROM pg_stat_user_tables ORDER BY pg_total_relation_size(relid) DESC;

Redis

# Redis CLI
docker compose exec redis redis-cli

# Check memory usage
redis-cli INFO memory

# Check connected clients
redis-cli INFO clients

On this page