Topic · Operations

Monitoring & logging for Django in production

Logs, errors, metrics, traces, uptime checks, and health endpoints, so problems are found before users report them.

signals that reach a personLogsMetricsErrorsUptimeAlert rulessymptoms, not noiseOn-callwith a runbookMonitor what users feel first; investigate with the rest

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.

5Set it up
22Run it well
5Check it
9Fix it

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.

Learning paths through this topic

Related topics