Monitoring & logging for Django in production
Logs, errors, metrics, traces, uptime checks, and health endpoints, so problems are found before users report them.
Monitoring tells you something is wrong before users do; logging tells you why. Together they turn an outage from guesswork into a short list of causes.
The guides cover structured logging, error tracking with Sentry, health checks and uptime alerts, metrics with Prometheus and Grafana, tracing, and log shipping.
Set it up
Guides that take this from nothing to running in production.
- Self-Host GlitchTip for Django Error Tracking
Run GlitchTip, the open-source Sentry-compatible error tracker, for Django: deploy it with PostgreSQL and Redis, point the standard sentry-sdk at a GlitchTip DSN, set up uptime checks and alerts, manage event retention, and keep it secure.
- Monitor Django With New Relic APM
Instrument a Django app with New Relic: install the Python agent, run Gunicorn and Celery under newrelic-admin, configure app names and environments, track transactions, database queries, and errors, add deploy markers, and control data ingest costs.
- Send Django Traces, Metrics, and Logs to SigNoz
Use SigNoz, an open-source OpenTelemetry-native observability platform, with Django: install OpenTelemetry instrumentation, export traces and metrics over OTLP, ship logs with trace IDs, self-host SigNoz or use SigNoz Cloud, and build dashboards and alerts.
- Monitor a Django Site With Uptime Kuma
Self-host Uptime Kuma to monitor Django: add HTTP checks against a health endpoint with keyword matching, monitor TLS expiry, use push monitors for Celery beat and cron jobs, send alerts to email, Slack, or Telegram, and publish a status page.
- Ship Django Logs With Vector
Use Vector to collect Django, Gunicorn, Nginx, and Celery logs from files, journald, or Docker, parse JSON logs, drop noise and redact secrets, enrich with host and environment, and send them to Loki, Elasticsearch, S3, or a hosted log service.
Run it well
Tuning, reliability, and operations once it works.
- How to Build a Django Health Check Endpoint for Deployments
A production Django deployment needs a reliable way to answer a simple question: is this instance safe to keep running and safe to receive traffic?
- Django Logging Setup for Production
A default Django project does not give you a production-safe logging setup.
- Set Up Sentry Error Monitoring for Django
Local logs are not enough once a Django app is in production. Exceptions can happen after deploys, during background jobs, or only under real user traffic patterns.
- How to Rotate Django and Gunicorn Logs on Linux
Django and Gunicorn log rotation becomes a production issue as soon as your app writes request logs, error logs, or application logs to disk for more than a few days.
- Monitor Django with Prometheus and Grafana
Expose Django metrics to Prometheus, handle Gunicorn multiprocess mode, add database and host exporters, build Grafana panels, and alert on what matters.
- Set Up Uptime Monitoring and Alerts for Django
Set up external uptime monitoring for Django: what to check, health endpoints, keyword and SSL checks, heartbeats for jobs, and alert routing.
- Add OpenTelemetry Tracing to Django
Add distributed tracing to Django with OpenTelemetry: instrument Django, PostgreSQL, Redis, and Celery, initialize safely under Gunicorn, and sample.
- Ship Django Logs to Grafana Loki
Centralise Django, Gunicorn, Celery, and Nginx logs in Grafana Loki: structured JSON logging, Grafana Alloy collecting from journald and files, low-cardinality labels, LogQL queries, and retention.
- Structured JSON Logging for Django
Switch Django to structured JSON logs for production: configure python-json-logger or structlog, include request ID, user, and timing fields, keep Gunicorn and Celery logs consistent, avoid logging secrets, and query logs in Loki, CloudWatch, or Datadog.
- Add Request IDs to Django Logs
Correlate Django logs per request with a request ID: accept or generate X-Request-ID at Nginx or the load balancer, store it in a contextvar, add it to every log line and Sentry event, return it to clients, and pass it to Celery tasks and outbound calls.
- Monitor Django With Datadog APM
Instrument a Django app with Datadog APM: install ddtrace, run Gunicorn under ddtrace-run, configure service, env, and version tags, trace Celery, PostgreSQL, and Redis, correlate logs with traces, and control cost with sampling.
- Send Django Logs to Amazon CloudWatch
Ship Django, Gunicorn, and Celery logs to Amazon CloudWatch Logs: the awslogs driver on ECS, the CloudWatch agent on EC2, JSON logs for Logs Insights queries, retention settings, metric filters and alarms, and controlling ingestion cost.
- Monitor Django Scheduled Jobs With Heartbeat Checks
Detect Django scheduled jobs that fail or silently stop running: heartbeat (dead man's switch) monitoring with Healthchecks.io, Cronitor, or your own endpoint, pinging start and success from management commands, Celery Beat, and Kubernetes CronJobs.
- Tune Sentry Sampling for Django Without Losing Important Data
Control Sentry volume and cost for Django: keep error sample_rate at 1.0, set traces_sample_rate or a traces_sampler that keeps slow and critical transactions, drop health checks and noisy errors with before_send, and use rate limits and spike protection.
- Reduce Django Log Volume and Logging Costs
Cut log volume from Django, Gunicorn, Nginx, and Celery without losing what matters: set sane log levels per logger, drop health check and static access logs, deduplicate access logging, sample high-volume info logs, and route debug detail to short retention.
- Monitor Celery with Flower
Run Flower to monitor Celery in a Django deployment: enable task events, run Flower under systemd bound to localhost, protect it with authentication behind Nginx, persist state, and export Prometheus metrics.
- Keep an Audit Log of Changes in Django
Record who changed what and when in a Django app: compare django-simple-history, django-auditlog, and pghistory triggers, capture the acting user and request ID, protect audit tables from tampering, plan retention, and keep audit writes fast.
- Liveness and Readiness Probes for Django on Kubernetes
Configure Kubernetes liveness, readiness, and startup probes for Django: separate cheap liveness and dependency-aware readiness endpoints, ALLOWED_HOSTS and HTTPS redirects, timeouts and thresholds, and avoiding restart storms during database outages.
- Log Slow PostgreSQL Queries From Django With log_min_duration_statement
Turn on PostgreSQL slow query logging for a Django app: set log_min_duration_statement, add auto_explain for plans, tag queries with application_name and SQL comments to find the view that sent them, and ship logs to your log platform without flooding it.
- Monitor Celery With Prometheus Metrics and Grafana
Expose Celery metrics to Prometheus for a Django app: run celery-exporter for task counts, failures, runtimes, and queue lengths, enable task events, build Grafana panels, and alert on growing queues, rising failures, and missing workers.
- Monitor TLS Certificate Expiry for Django Sites
Catch expiring HTTPS certificates before users do: check expiry from outside with uptime monitors, Prometheus blackbox exporter, or a scheduled script, cover every domain and certificate path, alert at 21 and 7 days, and verify that renewal actually reloads Nginx.
- Continuous Profiling for Django With Pyroscope
Add always-on continuous profiling to Django and Celery with Grafana Pyroscope: install the Python SDK or use eBPF, tag profiles by view and task, read flame graphs to find hot code paths, compare releases, and keep overhead low in production.
Check it
Review lists to run before launch or after a change.
- Django Monitoring and Alerting Checklist
Check monitoring coverage for a Django deployment: logs, errors, metrics, traces, uptime, background jobs, database signals, alert routing, and on-call practices.
- Django Incident Response Runbook
A runbook for Django production incidents: declare and assign roles, triage with a fixed checklist across proxy, app, workers, database, and cache, mitigate first, communicate, and run a blameless review.
- Django Observability Checklist: Logs, Metrics, Traces, and Alerts
A checklist for observability of a production Django system: structured logs with request IDs, RED metrics for web and Celery, distributed tracing, error tracking, database and queue visibility, SLO-based alerts, dashboards per service, and runbooks linked from alerts.
- Post-Deploy Verification Checklist for Django
Verify a Django release after every deploy: smoke tests, release version checks, migrations, static files, background jobs, and latency monitoring.
- Django SOC 2 Readiness Checklist
A technical readiness checklist for SOC 2 on a Django application: access control and MFA, change management through CI/CD, logging and monitoring, encryption, backups and recovery tests, vulnerability management, vendor review, and evidence collection.
Fix it
Errors and symptoms, each traced to a cause and a fix.
- Fix Django 500 Internal Server Error in Production
Find the real cause of a Django 500 error in production: where tracebacks go with DEBUG off, logging setup, common causes, safe reproduction, and verification.
- Fix Load Balancer Health Checks Failing for Django
Fix load balancer health checks that mark healthy Django servers down: DisallowedHost 400s, HTTPS redirects, auth on health paths, and slow checks.
- Fix Django Logs Not Showing in Production
Fix Django logging that shows nothing in production: why logger.info disappears with DEBUG off, configure LOGGING with console handlers, find Gunicorn and systemd output in journalctl, and capture errors from Celery.
- Fix Django Log File PermissionError [Errno 13] Permission Denied
Fix PermissionError Errno 13 Permission denied for a Django log file such as /var/log/django.log: give the app user ownership, stop root-run commands from creating the file, handle log rotation, or log to stdout instead.
- Fix Sentry Not Receiving Errors From Django in Production
Fix Sentry showing no events from a production Django app: check the DSN and environment, initialize sentry-sdk early in settings, make sure Celery and Gunicorn workers initialize too, and look for sampling, filters, rate limits, and blocked outbound traffic.
- Fix a Full Disk on a Django Production Server
Recover a Django server with a full disk: find what uses space, clean logs, journal, Docker images, and old releases safely, handle open files, add alerts.
- Fix a Django Docker Container Marked Unhealthy
Fix a Django Docker container stuck in unhealthy status: debug the HEALTHCHECK command, use a health endpoint that works without curl, ALLOWED_HOSTS and HTTPS redirects, start_period for migrations, and dependent services.
- Stop Docker Logs From Filling the Disk on a Django Host
Stop Docker container logs from filling the disk on a Django server: find the large json.log files, set max-size and max-file in daemon.json or Compose, use the local driver, and reduce noisy logging.
- Fix Django Logs and print() Output Not Showing in docker logs
Fix Django, Gunicorn, and Celery output missing from docker logs or appearing late: set PYTHONUNBUFFERED, log to stdout instead of files, configure Gunicorn access and error logs, and keep LOGGING from silencing django.request errors.
Learning paths through this topic
- Background jobs with CelerySet up workers and Beat, keep them supervised, route and tune them, and make tasks safe to retry.
- Releases without downtimeScript the release, make migrations backward compatible, and switch, verify, or roll back without users noticing.
- Keeping it runningLogs, errors, metrics, uptime, backups, and the runbooks you need before the first incident.
- Django on KubernetesRun Django on a cluster with config, ingress, probes, jobs, graceful shutdown, and autoscaling, then package it with Helm and GitOps.