Skip to main content

A reusable Django app for auditing models automatically with Kafka integration

Project description

Django Audit Logger

django-audit-logger is a reusable Django app that automatically audits model changes (create, update, delete) across all models in your Django project. It integrates with Kafka for log streaming and allows flexible configuration auditing for important models. The app captures useful metadata such as the user who made the changes, request IP, URL, and more.

Features

  • Automatic Auditing: Automatically register all Django models for audit logging after migrations.
  • Kafka Integration: Uses confluent_kafka to send audit logs to Kafka topics.
  • Configuration Auditing: Manually register important models for configuration auditing.
  • User Context Middleware: Captures information about the user, request IP, and user agent via middleware.
  • Customizable: You can extend or override middleware, and control the Kafka producer behavior.

Installation

  1. INSTALL the package using pip:

    pip install django-audit-kafkalogger
    
  2. Add it to your Django INSTALLED_APPS:

    In your settings.py, configure the apps:

    INSTALLED_APPS = [
       # Other installed apps
       'audit_logger',
    ]
    
  3. Add the MIDDLEWARE:

    In your settings.py, configure the middlewares:

    MIDDLEWARE = [
       # Other middlewares
       'audit_logger.middlewares.AuditUserMiddleware',
    ]
    
  4. Add KAFKA CONFIGURATION:

    In your settings.py, configure the Kafka broker and topics:

    KAFKA_BROKER_URL = 'localhost:9092'  # Replace with your Kafka broker URL
    KAFKA_TOPIC_LOGS = 'audit_logs'      # Topic for log auditing
    KAFKA_TOPIC_ERRORS = 'audit_errors'  # Topic for error logging
    KAFKA_TOPIC_CONFIG = 'audit_config'  # Topic for configuration auditing
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_audit_kafkalogger-0.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

django_audit_kafkalogger-0.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file django_audit_kafkalogger-0.2.tar.gz.

File metadata

File hashes

Hashes for django_audit_kafkalogger-0.2.tar.gz
Algorithm Hash digest
SHA256 520cbb0d5ed77fe928de597944cd238a75dfa37be699e290fef0c108857cfcdb
MD5 7db22d633b60d2c8346c53eccb7cb545
BLAKE2b-256 25871ef77421685a9dac91272d641da8dc26ff05737a45b4a4e9d238ba55b7e3

See more details on using hashes here.

File details

Details for the file django_audit_kafkalogger-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_audit_kafkalogger-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3442f3b14ae426d4f30e2bd65f1b5b1322c32ab5bae0cb9269c2f8254277183
MD5 eed831de5743fb27140a8012a14c9fb0
BLAKE2b-256 7de5e163a88975a7edbf7651ae1062ba6fb1192c8a80f28c00442134c421ab9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page