Skip to content

Commit

Permalink
feat: enable alerts and reports in superset
Browse files Browse the repository at this point in the history
fixes #46
  • Loading branch information
Danyal-Faheem committed Feb 14, 2025
1 parent 71ebd13 commit 2ae1a46
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Improvement] Enable Alerts and Reports in superset. (by @Danyal-Faheem)
25 changes: 20 additions & 5 deletions tutorcairn/templates/cairn/apps/superset/superset_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="*"),
Expand All @@ -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
Expand Down
17 changes: 14 additions & 3 deletions tutorcairn/templates/cairn/build/cairn-superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 2ae1a46

Please sign in to comment.