mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[log] New, make action log configurable and generic (#7705)
* [log] New, make action log configurable and generic * [log] Fix, missing apache license * [log] Fix, user_id is a required parameter on event logs * [log] Fix, Rename Action to Event * [log] Fix, flake8 * [logger] Change all log_this decorators to new abstract one * [logger] [docs] Simple docs to show how to override the event log * [style] Fix, single quote to double quote * [style] Fix, single quote to double quote
This commit is contained in:
committed by
Maxime Beauchemin
parent
f5839c413e
commit
1ab04190cd
@@ -678,6 +678,40 @@ environment variable: ::
|
||||
|
||||
*Adapted from http://flask.pocoo.org/snippets/69/*
|
||||
|
||||
Event Logging
|
||||
-------------
|
||||
|
||||
Superset by default logs special action event on it's database. These log can be accessed on the UI navigating to
|
||||
"Security" -> "Action Log". You can freely customize these logs by implementing your own event log class.
|
||||
|
||||
Example of a simple JSON to Stdout class::
|
||||
|
||||
class JSONStdOutEventLogger(AbstractEventLogger):
|
||||
|
||||
def log(self, user_id, action, *args, **kwargs):
|
||||
records = kwargs.get('records', list())
|
||||
dashboard_id = kwargs.get('dashboard_id')
|
||||
slice_id = kwargs.get('slice_id')
|
||||
duration_ms = kwargs.get('duration_ms')
|
||||
referrer = kwargs.get('referrer')
|
||||
|
||||
for record in records:
|
||||
log = dict(
|
||||
action=action,
|
||||
json=record,
|
||||
dashboard_id=dashboard_id,
|
||||
slice_id=slice_id,
|
||||
duration_ms=duration_ms,
|
||||
referrer=referrer,
|
||||
user_id=user_id
|
||||
)
|
||||
print(json.dumps(log))
|
||||
|
||||
|
||||
Then on Superset's config reference the class you want to use::
|
||||
|
||||
EVENT_LOGGER = JSONStdOutEventLogger
|
||||
|
||||
|
||||
Upgrading
|
||||
---------
|
||||
|
||||
Reference in New Issue
Block a user