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
-
INSTALL the package using pip:
pip install django-audit-logger
-
Add it to your Django INSTALLED_APPS:
In your
settings.py
, configure the apps:INSTALLED_APPS = [ # Other installed apps 'audit_logger', ]
-
Add the MIDDLEWARE:
In your
settings.py
, configure the middlewares:MIDDLEWARE = [ # Other middlewares 'audit_logger.middlewares.AuditUserMiddleware', ]
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file django_audit_kafkalogger-0.1-py3-none-any.whl
.
File metadata
- Download URL: django_audit_kafkalogger-0.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f55104e2a2c263e711c73658c1505e5e68e134777653bc5727be194c5508773 |
|
MD5 | a4af50d9ae8744401e3ffd0137834d2c |
|
BLAKE2b-256 | 59d6a7897640d8cf0ac2488ee51e5a67a3b1c14e90f10f0bf88220cd0eb41144 |