dosubot[bot] commented on issue #36860:
URL: https://github.com/apache/superset/issues/36860#issuecomment-3701806203
<!-- Answer -->
Yes, you can log the exact SQL statements (including CREATE VIEW) that
Superset sends to your database, but setting the DEBUG environment variable
alone is not enough. You need to enable SQLAlchemy's SQL logging.
For a Helm/Kubernetes deployment, the recommended approach is to use the
configOverrides field in your values.yaml to append to superset_config.py. Add
the following override to enable SQL statement logging:
```yaml
configOverrides:
enable_sqlalchemy_echo: |
SQLALCHEMY_ENGINE_OPTIONS = {"echo": True}
```
Alternatively, you can set this in a custom superset_config.py if you mount
one.
If you want to increase overall log verbosity, you can also set:
```yaml
extraEnv:
SUPERSET_LOG_LEVEL: "debug"
```
With these settings, all SQL statements (including CREATE VIEW) will be
logged to stdout/stderr, which means you can see them in your pod logs via
kubectl logs or your cluster's log aggregation. If you want persistent logs,
you can also enable file logging in superset_config.py, but for most Kubernetes
setups, stdout/stderr is preferred
[reference](https://github.com/apache/superset/discussions/34404)
[reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/helm/superset/values.yaml#L18-L900).
Remember to remove or revert these changes after debugging, as SQL logging
can be very verbose and may impact performance.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do?
[Good](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/c56fa9ae-cf34-48a7-8ea3-9118f89bfd46?feedback_type=other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=Yes%2C%20you%20can%20log%20the%20exact%20SQL%20statements%20%28including%20CREATE%20VIEW%29%20that%20Superset%20sends%20to%20your%20database%2C%20but%20setting%20the%20DEBUG%20environment%20variable%20alone%20is%20not%20enough.%20You%20need%20to%20enable%20SQLAlchemy%27s%20SQL%20logging.%0A%0AFor%20a%20Helm/Kubernetes%20deployment%2C%20the%20recommended%20approach%20is%20to%20use%20the%20configOverrides%20field%20in%20your%20values.yaml%20to%20append%20to%20superset_config.py.%20Add%20the%20following%20override%20to%20enable%20SQL%20statement%20logging%3A%0A%0A%60%60%60yaml%0AconfigOverrides%3A%0A%20%20enable_sqlalchemy_echo%3A%20%7C%0A%20%20%20%20SQLALCHEMY_ENGINE_OPTIONS%20%3D%20%7B%22echo%22%3A%20True%7D%0A%60%60%60%0A%0AAlternatively%2C%20you%2
0can%20set%20this%20in%20a%20custom%20superset_config.py%20if%20you%20mount%20one.%0A%0AIf%20you%20want%20to%20increase%20overall%20log%20verbosity%2C%20you%20can%20also%20set%3A%0A%0A%60%60%60yaml%0AextraEnv%3A%0A%20%20SUPERSET_LOG_LEVEL%3A%20%22debug%22%0A%60%60%60%0A%0AWith%20these%20settings%2C%20all%20SQL%20statements%20%28including%20CREATE%20VIEW%29%20will%20be%20logged%20to%20stdout/stderr%2C%20which%20means%20you%20can%20see%20them%20in%20your%20pod%20logs%20via%20kubectl%20logs%20or%20your%20cluster%27s%20log%20aggregation.%20If%20you%20want%20persistent%20logs%2C%20you%20can%20also%20enable%20file%20logging%20in%20superset_config.py%2C%20but%20for%20most%20Kubernetes%20setups%2C%20stdout/stderr%20is%20preferred%20%5Breference%5D%28https%3A//github.com/apache/superset/discussions/34404%29%20%5Breference%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/helm/superset/values.yaml%23L18-L900%29.%0A%0ARemember%20to%20remove%20or%20revert%2
0these%20changes%20after%20debugging%2C%20as%20SQL%20logging%20can%20be%20very%20verbose%20and%20may%20impact%20performance.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/36860)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]