Tracks CKAN Action API usage and resource downloads with the entities each
request touches. Every /api/{version}/action/{action} request and every
resource download produces one JSON event on the ckanext.analytics.event
logger.
Each event contains request metadata (timestamp, request_id, service,
method, endpoint, query_string, action_type, status_code,
user_agent, request_ip, and user) plus these entity names when they
can be resolved:
datasetresourceorganizationgroup
Downloads are recorded with action_type set to resource_download,
attributed to the resource and dataset in the URL - including redirects to
externally linked resources (302) and refused attempts. Failed API calls are
recorded with their final HTTP status. Web pages and static files are not
tracked.
pip install -e .Enable the plugin in the CKAN configuration:
ckan.plugins = ... analyticsThe plugin subscribes one listener to CKAN's request_finished signal. The
listener filters Action API and resource download requests, extracts entity
references from request parameters, resolves their names through CKAN's
model, and writes the event.
Entity lookup results are cached in each CKAN process for five minutes.
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -o addopts='' \
ckanext/analytics/testsAGPL-3.0-or-later