mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
docs: pypi-installation on Ubuntu 24.04 and statsd package for event-logging (#32891)
This commit is contained in:
@@ -51,6 +51,7 @@ if desired. Most endpoints hit are logged as
|
||||
well as key events like query start and end in SQL Lab.
|
||||
|
||||
To setup StatsD logging, it’s a matter of configuring the logger in your `superset_config.py`.
|
||||
If not already present, you need to ensure that the `statsd`-package is installed in Superset's python environment.
|
||||
|
||||
```python
|
||||
from superset.stats_logger import StatsdStatsLogger
|
||||
|
||||
@@ -22,6 +22,13 @@ level dependencies.
|
||||
|
||||
**Debian and Ubuntu**
|
||||
|
||||
Ubuntu **24.04** uses python 3.12 per default, which currently is not supported by Superset. You need to add a second python installation of 3.11 and install the required additional dependencies.
|
||||
```bash
|
||||
sudo add-apt-repository ppa:deadsnakes/ppa
|
||||
sudo apt update
|
||||
sudo apt install python3.11 python3.11-dev python3.11-venv build-essential libssl-dev libffi-dev libsasl2-dev libldap2-dev default-libmysqlclient-dev
|
||||
```
|
||||
|
||||
In Ubuntu **20.04 and 22.04** the following command will ensure that the required dependencies are installed:
|
||||
|
||||
```bash
|
||||
@@ -94,14 +101,9 @@ These will now be available when pip installing requirements.
|
||||
|
||||
## Python Virtual Environment
|
||||
|
||||
We highly recommend installing Superset inside of a virtual environment. Python ships with
|
||||
`virtualenv` out of the box. If you're using [pyenv](https://github.com/pyenv/pyenv), you can install [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv). Or you can install it with `pip`:
|
||||
We highly recommend installing Superset inside of a virtual environment.
|
||||
|
||||
```bash
|
||||
pip install virtualenv
|
||||
```
|
||||
|
||||
You can create and activate a virtual environment using:
|
||||
You can create and activate a virtual environment using the following commands. Ensure you are using a compatible version of python. You might have to explicitly use for example `python3.11` instead of `python3`.
|
||||
|
||||
```bash
|
||||
# virtualenv is shipped in Python 3.6+ as venv instead of pyvenv.
|
||||
@@ -132,7 +134,7 @@ pip install apache_superset
|
||||
|
||||
Then, define mandatory configurations, SECRET_KEY and FLASK_APP:
|
||||
```bash
|
||||
export SUPERSET_SECRET_KEY=YOUR-SECRET-KEY
|
||||
export SUPERSET_SECRET_KEY=YOUR-SECRET-KEY # For production use, make sure this is a strong key, for example generated using `openssl rand -base64 42`. See https://superset.apache.org/docs/configuration/configuring-superset#specifying-a-secret_key
|
||||
export FLASK_APP=superset
|
||||
```
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
from typing import Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from colorama import Fore, Style
|
||||
|
||||
@@ -105,5 +105,27 @@ try:
|
||||
def gauge(self, key: str, value: float) -> None:
|
||||
self.client.gauge(key, value)
|
||||
|
||||
except Exception: # pylint: disable=broad-except # noqa: S110
|
||||
pass
|
||||
except Exception as e: # pylint: disable=broad-except # noqa: S110
|
||||
# e can only be accessed in the catch and not later during class instantiation.
|
||||
# We have to save it to a separate variable.
|
||||
_saved_exception = e
|
||||
|
||||
class StatsdStatsLogger(BaseStatsLogger): # type:ignore[no-redef] # the redefinition only happens when the original definition failed
|
||||
def __init__( # pylint: disable=super-init-not-called
|
||||
self,
|
||||
host: str = "localhost",
|
||||
port: int = 8125,
|
||||
prefix: str = "superset",
|
||||
statsd_client: Any = None,
|
||||
) -> None:
|
||||
"""
|
||||
Initializes from either params or a supplied, pre-constructed statsd client.
|
||||
|
||||
If statsd_client argument is given, all other arguments are ignored and the
|
||||
supplied client will be used to emit metrics.
|
||||
|
||||
If an exception is raised while creating the StatsdStatsLogger class, for
|
||||
example because the statsd package is not installed, it will be re-raised
|
||||
on instantiation of the StatsdStatsLogger.
|
||||
"""
|
||||
raise _saved_exception
|
||||
|
||||
Reference in New Issue
Block a user