Extension Event Audit


Extension Basics

Title
Event Audit
Name
ckanext-event-audit
Type
Public extension
Description
Erfasst und speichert umfassende Audit-Logs aller Änderungen in CKAN (Actions, Model-Changes) mit flexiblen Repositories (Redis, Database, CloudWatch) und Export-Funktionen.
CKAN versions

~2.9, ~2.10, ~2.11

Show details
Download-Url (zip)
Download-Url commit date
2024-11-25
Url to repo
Category
Data Management & Quality


Background Infos

Description (long)
Show details

ckanext-event-audit

Umfassende Audit-Lösung für CKAN mit folgenden Features:

Event-Erfassung:

  • Action-Tracking: Alle API-Aktionen mit Payload und Results
  • Model-Tracking: Automatisches Tracking von SQLAlchemy Model-Änderungen (create/update/delete)
  • User-Context: User-ID, IP-Adresse, User-Agent
  • Timestamps: created_at mit Millisekunden-Präzision
  • Categories: Kategorisierung von Events
  • Flexible Ignore-Listen für Actions und Models

Repository-Optionen:

  1. Basic (Database): PostgreSQL mit migration support
  2. Redis: In-Memory Storage mit Persistence
  3. CloudWatch: AWS CloudWatch Logs Integration
  4. Custom: Eigene Repository-Implementierung möglich

Admin-Panel:

  • Event-Liste mit Filter/Sortierung
  • Detail-View mit JSON-Payload
  • Export-Funktionen (CSV, TSV, JSON, XLSX)
  • Pagination
  • ckanext-admin-panel Integration

Exporters:

  • Basic: Python Dict Format
  • CSV/TSV: Tabellarisch mit configurable delimiter
  • JSON: Strukturierte JSON-Arrays
  • XLSX: Excel mit openpyxl (optional)
  • Custom Exporter: Eigene Implementierung

Konfiguration:

  • Ignore Categories/Actions/Models
  • Track nur spezifische Models
  • Async Processing Support
  • Repository Restriction
  • Payload/Result Storage Toggle
  • CloudWatch AWS Credentials

CLI:

ckan event-audit export --format=csv --output=audit.csv
ckan event-audit export --format=xlsx --output=audit.xlsx --start-date=2024-01-01
ckan event-audit clear --confirm

Interfaces:

  • IEventAudit: before_audit, after_audit hooks
  • Custom validators für Event-Daten

Lizenz: AGPL-3.0

Version
1.0.1
Version release date
2024-11-25
Contact name
DataShades
Contakt email
(not set)
Contact Url
(not set)


Installation Guide

Configuration hints

Installation

pip install ckanext-event-audit

Mit XLSX Export (optional)

pip install ckanext-event-audit[xlsx]

Configuration

ckan.plugins = … event_audit …

DB Migration

ckan db upgrade -p event_audit

Repository Konfiguration:

Active Repository (default: redis)

ckanext.event_audit.active_repo = redis # oder: basic, cloudwatch, custom

Verfügbare Repos einschränken (optional)

ckanext.event_audit.restrict_available_repos = redis basic

CloudWatch Configuration (bei cloudwatch repo):

ckanext.event_audit.cloudwatch.access_key = YOUR_ACCESS_KEY ckanext.event_audit.cloudwatch.secret_key = YOUR_SECRET_KEY ckanext.event_audit.cloudwatch.region = us-east-1 ckanext.event_audit.cloudwatch.log_group = /ckan/event-audit ckanext.event_audit.cloudwatch.log_stream = event-audit-stream

Event Filtering:

Ignorierte Categories (Komma-separiert)

ckanext.event_audit.ignore.categories = test,debug

Ignorierte Actions (default: resource_view_list, user_show, etc.)

ckanext.event_audit.ignore.actions = package_search,package_show

Ignorierte Models (default: Option)

ckanext.event_audit.ignore.models = User,Package

Nur spezifische Models tracken (hat Priorität über ignore)

ckanext.event_audit.track.models = Package,Resource,User

Admin Panel:

Admin-Panel aktivieren (default: false)

ckanext.event_audit.enable_admin_panel = true

Performance:

Payload/Result Storage deaktivieren (weniger Speicher)

ckanext.event_audit.store_payload_and_result = false

Model Tracking deaktivieren

ckanext.event_audit.track_models = false

CLI Nutzung:

Export Events to CSV

ckan event-audit export –format=csv –output=/tmp/audit.csv

Export mit Datumsfilter

ckan event-audit export –format=json –start-date=2024-01-01 –end-date=2024-12-31

Export to XLSX (requires openpyxl)

ckan event-audit export –format=xlsx –output=audit.xlsx

Clear all events (VORSICHT!)

ckan event-audit clear –confirm

API Usage:

Events abrufen

events = tk.get_action(‘event_audit_get_events’)( context, { ‘category’: ‘package’, ‘user_id’: ‘user-123’, ‘limit’: 100, ‘offset’: 0 } )

Event manuell erstellen

tk.get_action(‘event_audit_create_event’)( context, { ‘category’: ‘custom’, ‘action’: ‘my_custom_action’, ‘actor’: tk.current_user.id, ‘payload’: {‘key’: ‘value’}, ‘result’: {‘status’: ‘success’} } )

Custom Repository Implementation:

from ckanext.event_audit.repositories import AbstractRepository

class MyCustomRepo(AbstractRepository): def write_event(self, event_dict): # Custom storage logic pass

def read_events(self, filters):
    # Custom retrieval logic
    return []

Registrierung in plugin.py

from ckanext.event_audit.repositories import register_repository

register_repository(‘mycustom’, MyCustomRepo)

Plugins to configure (ckan.ini)
event_audit
CKAN Settings (ckan.ini)
# ckanext.event_audit.active_repo = redis # oder: basic, cloudwatch, custom # ckanext.event_audit.restrict_available_repos = redis basic # ckanext.event_audit.cloudwatch.access_key = YOUR_ACCESS_KEY # ckanext.event_audit.cloudwatch.secret_key = YOUR_SECRET_KEY # ckanext.event_audit.cloudwatch.region = us-east-1 # ckanext.event_audit.cloudwatch.log_group = /ckan/event-audit # ckanext.event_audit.cloudwatch.log_stream = event-audit-stream # ckanext.event_audit.ignore.categories = test,debug # ckanext.event_audit.ignore.actions = package_search,package_show # ckanext.event_audit.ignore.models = User,Package # ckanext.event_audit.track.models = Package,Resource,User # ckanext.event_audit.enable_admin_panel = true # ckanext.event_audit.store_payload_and_result = false # ckanext.event_audit.track_models = false
DB migration to be executed
event_audit
<< back to Extensions