-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Logging Class not working #15548
Comments
Hello! Have you solved this issue somehow or found some workaround for that? |
Hello, yes we managed to fix it. It turned out that logs were not written at the right place by the logging class. We added this to the code :
The full code snippet is now:
|
Thanks a lot for your answer. |
Sure you can do it, hope it can help people. |
I've managed to do both JSONStdOutEventLogger and DBEventLogger at the same time. Now events are saved to logs in JSON format and they are still visible in Superset's dashboard in activity tab.
|
Hi! My last PR is merged, finally I've just updated docs. I think this issue could be closed now? |
If anyone is coming here in 2024. This is what worked for us with the Superset Helm Chart # values.yaml file:
configOverrides:
# We use a custom JSON logger here to output everything to stdout -> FluentBit
# Also, we prevent superset from using the default logger and flooding the DB with Logs
# More info: https://superset.apache.org/docs/configuration/event-logging/
logger_settings: |
# log everything as JSON
from superset.utils.log import AbstractEventLogger
import json
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))
# use JSON logger and disable logging to the DB Table
EVENT_LOGGER = JSONStdOutEventLogger() This code creates a new logger that will log events as JSON in stdout and then prevent the DB Table from overflowing from time to time. The logs can then be flushed out from stdout to a search tool using a logger daemon. If desired, I can help to update the Kubernetes Docs with this 🧡 |
Hi !
I am currently trying to use a custom EVENT_LOGGER in superset, i added the code snippets from the official doc but it isn't working:
I think the EVENT_LOGGER has changed and isn't the default DBEventLogger() anymore because we have some new logs on stdout, and there are no more "action logs" in the superset UI.
However, my JSONStdOutEventLogger() isn't used either, i added some prints in the log method to see if it was even called, and it doesn't seem so.
Here are the code snippets i added:
Expected results
I expect the custom log method to be used (ie to see "bip boup" and "bip boup 2" on stdout)
Actual results
Some debug logs and logs on the requests done are on stdout (cf screenshot)
Screenshots
Environment
I hope i'm not missing something, thank in advance for your help !
The text was updated successfully, but these errors were encountered: