From 2ae1a465b6962fdd9d1a752447c7858dd1f1359a Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Fri, 14 Feb 2025 21:32:05 +0500 Subject: [PATCH] feat: enable alerts and reports in superset fixes #46 --- ...025_danyal.faheem_enable_alerts_reports.md | 1 + .../cairn/apps/superset/superset_config.py | 25 +++++++++++++++---- .../cairn/build/cairn-superset/Dockerfile | 17 ++++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 changelog.d/20250214_213025_danyal.faheem_enable_alerts_reports.md diff --git a/changelog.d/20250214_213025_danyal.faheem_enable_alerts_reports.md b/changelog.d/20250214_213025_danyal.faheem_enable_alerts_reports.md new file mode 100644 index 0000000..4a5018a --- /dev/null +++ b/changelog.d/20250214_213025_danyal.faheem_enable_alerts_reports.md @@ -0,0 +1 @@ +[Improvement] Enable Alerts and Reports in superset. (by @Danyal-Faheem) \ No newline at end of file diff --git a/tutorcairn/templates/cairn/apps/superset/superset_config.py b/tutorcairn/templates/cairn/apps/superset/superset_config.py index 27e4df0..8e60907 100644 --- a/tutorcairn/templates/cairn/apps/superset/superset_config.py +++ b/tutorcairn/templates/cairn/apps/superset/superset_config.py @@ -142,10 +142,6 @@ class CeleryConfig: # pylint: disable=too-few-public-methods }, } CELERYBEAT_SCHEDULE = { - "email_reports.schedule_hourly": { - "task": "email_reports.schedule_hourly", - "schedule": crontab(minute=1, hour="*"), - }, "reports.scheduler": { "task": "reports.scheduler", "schedule": crontab(minute="*", hour="*"), @@ -159,13 +155,32 @@ class CeleryConfig: # pylint: disable=too-few-public-methods CELERY_CONFIG = CeleryConfig +# Email configuration +SMTP_HOST = "{{ SMTP_HOST }}" +SMTP_PORT = {{ SMTP_PORT }} +SMTP_STARTTLS = {{ SMTP_USE_TLS }} +SMTP_SSL = {{ SMTP_USE_SSL }} +SMTP_USER = "{{ SMTP_USERNAME }}" # use the empty string "" if using an unauthenticated SMTP server +SMTP_PASSWORD = "{{ SMTP_PASSWORD }}" # use the empty string "" if using an unauthenticated SMTP server +SMTP_MAIL_FROM = "{{ CONTACT_EMAIL }}" +EMAIL_REPORTS_SUBJECT_PREFIX = "[{{ PLATFORM_NAME }}] " + +ALERT_REPORTS_NOTIFICATION_DRY_RUN = False +WEBDRIVER_BASEURL = "http://cairn-superset:8000/" +# The base URL for the email report hyperlinks. +WEBDRIVER_BASEURL_USER_FRIENDLY = "{{ CAIRN_HOST }}" + +WEBDRIVER_OPTION_ARGS = ["--headless"] + # Avoid duplicate logging because of propagation to root logger logging.getLogger("superset").propagate = False # https://github.com/apache/superset/blob/master/RESOURCES/FEATURE_FLAGS.md FEATURE_FLAGS = { # Enable dashboard embedding - "EMBEDDED_SUPERSET": True + "EMBEDDED_SUPERSET": True, + "ALERT_REPORTS": True, + } ENABLE_CORS=True diff --git a/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile b/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile index 9ec0368..fd61ae6 100644 --- a/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile +++ b/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile @@ -7,15 +7,26 @@ FROM docker.io/apache/superset:4.0.0 USER root +# https://github.com/apache/superset/blob/4.0.0/Dockerfile#L109-L110 +# Extracted from https://superset.apache.org/docs/installation/alerts-reports/#custom-dockerfile +ARG GECKODRIVER_VERSION=v0.33.0 \ + FIREFOX_VERSION=117.0.1 + # https://pypi.org/project/clickhouse-driver/ # https://pypi.org/project/mysqlclient/ # https://pypi.org/project/clickhouse-connect/ # https://pypi.org/project/clickhouse-sqlalchemy/ # https://pypi.org/project/Authlib/ # We preserve the clickhouse-sqlalchemy package to keep backward compatibility with existing dashboards -RUN apt-get update \ - && apt-get install -y \ - pkg-config +RUN apt-get update -qq \ + && apt-get install -yqq --no-install-recommends wget bzip2 git \ + # Mysql dependencies + default-libmysqlclient-dev build-essential pkg-config gcc \ + && wget -q https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O - | tar xfz - -C /usr/local/bin \ + # Install Firefox + && wget -q https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 -O - | tar xfj - -C /opt \ + && ln -s /opt/firefox/firefox /usr/local/bin/firefox \ + && apt-get autoremove -yqq --purge wget bzip2 && rm -rf /var/[log,tmp]/* /tmp/* /var/lib/apt/lists/* RUN --mount=type=cache,target=/root/.cache/pip,sharing=shared pip install \ clickhouse-driver==0.2.7 \