You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gugacavalieri (via GitHub)" <gi...@apache.org> on 2024/08/28 18:00:09 UTC

Re: [I] Custom Logging Class not working [superset]

gugacavalieri commented on issue #15548:
URL: https://github.com/apache/superset/issues/15548#issuecomment-2315956101

   If anyone is coming here in 2024. This is what worked for us with the Superset Helm Chart `0.12.9` version: (We are running Superset in Kubernetes)
   
   ```yaml
   # 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,
                     message=f"Action: {action} | DashID: {dashboard_id} | Time: {duration_ms}",
                     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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org