blob: bcbb04474f629f5b9d78d05b5945cacd92f7f1be [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[55],{Khln:function(e,n,t){"use strict";t.r(n),t.d(n,"_frontmatter",(function(){return s})),t.d(n,"default",(function(){return b}));var a=t("k1TG"),r=t("8o2o"),o=(t("q1tI"),t("7ljp")),i=t("hhGP"),s=(t("qKvR"),{});void 0!==s&&s&&s===Object(s)&&Object.isExtensible(s)&&!s.hasOwnProperty("__filemeta")&&Object.defineProperty(s,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/pages/docs/installation/alerts_reports.mdx"}});var l={_frontmatter:s},c=i.a;function b(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(o.b)(c,Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"alerts-and-reports"},"Alerts and Reports"),Object(o.b)("p",null,"(version 1.0.1 and above)"),Object(o.b)("p",null,"Users can configure automated alerts and reports to send dashboards or charts to an email recipient or Slack channel."),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"Alerts are sent when a SQL condition is reached"),Object(o.b)("li",{parentName:"ul"},"Reports are sent on a schedule")),Object(o.b)("p",null,"Alerts and reports are disabled by default. To turn them on, you need to do some setup, described here."),Object(o.b)("h3",{id:"requirements"},"Requirements"),Object(o.b)("h4",{id:"commons"},"Commons"),Object(o.b)("h5",{id:"in-your-superset_configpy"},"In your ",Object(o.b)("inlineCode",{parentName:"h5"},"superset_config.py")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},'"ALERT_REPORTS"')," feature flag must be turned to True."),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"CELERYBEAT_SCHEDULE")," in CeleryConfig must contain schedule for ",Object(o.b)("inlineCode",{parentName:"li"},"reports.scheduler"),"."),Object(o.b)("li",{parentName:"ul"},"At least one of those must be configured, depending on what you want to use:",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"emails: ",Object(o.b)("inlineCode",{parentName:"li"},"SMTP_*")," settings"),Object(o.b)("li",{parentName:"ul"},"Slack messages: ",Object(o.b)("inlineCode",{parentName:"li"},"SLACK_API_TOKEN"))))),Object(o.b)("h5",{id:"in-your-dockerfile"},"In your ",Object(o.b)("inlineCode",{parentName:"h5"},"Dockerfile")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"You must install a headless browser, for taking screenshots of the charts and dashboards. Only Firefox and Chrome are currently supported.",Object(o.b)("blockquote",{parentName:"li"},Object(o.b)("p",{parentName:"blockquote"},"If you choose Chrome, you must also change the value of ",Object(o.b)("inlineCode",{parentName:"p"},"WEBDRIVER_TYPE")," to ",Object(o.b)("inlineCode",{parentName:"p"},'"chrome"')," in your ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py"),".")))),Object(o.b)("h4",{id:"slack-integration"},"Slack integration"),Object(o.b)("p",null,"To send alerts and reports to Slack channels, you need to create a new Slack Application on your workspace."),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"Connect to your Slack workspace, then head to ",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://api.slack.com/apps"}),"https://api.slack.com/apps"),"."),Object(o.b)("li",{parentName:"ol"},"Create a new app."),Object(o.b)("li",{parentName:"ol"},'Go to "OAuth & Permissions" section, and give the following scopes to your app:',Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"incoming-webhook")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"files:write")))),Object(o.b)("li",{parentName:"ol"},'At the top of the "OAuth and Permissions" section, click "install to workspace".'),Object(o.b)("li",{parentName:"ol"},"Select a default channel for your app and continue.\n(You can post to any channel by inviting your Superset app into that channel)."),Object(o.b)("li",{parentName:"ol"},'The app should now be installed in your workspace, and a "Bot User OAuth Access Token" should have been created. Copy that token in the ',Object(o.b)("inlineCode",{parentName:"li"},"SLACK_API_TOKEN")," variable of your ",Object(o.b)("inlineCode",{parentName:"li"},"superset_config.py"),"."),Object(o.b)("li",{parentName:"ol"},"Restart the service (or run ",Object(o.b)("inlineCode",{parentName:"li"},"superset init"),") to pull in the new configuration.")),Object(o.b)("p",null,"Note: when you configure an alert or a report, the Slack channel list take channel names without the leading '#' e.g. use ",Object(o.b)("inlineCode",{parentName:"p"},"alerts")," instead of ",Object(o.b)("inlineCode",{parentName:"p"},"#alerts"),"."),Object(o.b)("h4",{id:"kubernetes-specific"},"Kubernetes specific"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"You must have a ",Object(o.b)("inlineCode",{parentName:"li"},"celery beat")," pod running. If you're using the chart included in the GitHub repository under ",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://github.com/apache/superset/tree/master/helm/superset"}),"helm/superset"),", you need to put ",Object(o.b)("inlineCode",{parentName:"li"},"supersetCeleryBeat.enabled = true")," in your values override."),Object(o.b)("li",{parentName:"ul"},"You can see the dedicated docs about ",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"/docs/installation/running-on-kubernetes"}),"Kubernetes installation")," for more generic details.")),Object(o.b)("h4",{id:"docker-compose-specific"},"Docker-compose specific"),Object(o.b)("h5",{id:"you-must-have-in-yourdocker-composeyaml"},"You must have in your",Object(o.b)("inlineCode",{parentName:"h5"},"docker-compose.yaml")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"a redis message broker"),Object(o.b)("li",{parentName:"ul"},"PostgreSQL DB instead of SQLlite"),Object(o.b)("li",{parentName:"ul"},"one or more ",Object(o.b)("inlineCode",{parentName:"li"},"celery worker")),Object(o.b)("li",{parentName:"ul"},"a single ",Object(o.b)("inlineCode",{parentName:"li"},"celery beat"))),Object(o.b)("h3",{id:"detailed-config"},"Detailed config"),Object(o.b)("p",null,"The following configurations need to be added to the ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," file. This file is loaded when the image runs, and any configurations in it will override the default configurations found in the ",Object(o.b)("inlineCode",{parentName:"p"},"config.py"),"."),Object(o.b)("p",null,"You can find documentation about each field in the default ",Object(o.b)("inlineCode",{parentName:"p"},"config.py")," in the GitHub repository under ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/apache/superset/blob/master/superset/config.py"}),"superset/config.py"),"."),Object(o.b)("p",null,"You need to replace default values with your custom Redis, Slack and/or SMTP config."),Object(o.b)("p",null,"In the ",Object(o.b)("inlineCode",{parentName:"p"},"CeleryConfig"),", only the ",Object(o.b)("inlineCode",{parentName:"p"},"CELERYBEAT_SCHEDULE")," is relative to this feature, the rest of the ",Object(o.b)("inlineCode",{parentName:"p"},"CeleryConfig")," can be changed for your needs."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"from celery.schedules import crontab\n\nFEATURE_FLAGS = {\n \"ALERT_REPORTS\": True\n}\n\nREDIS_HOST = \"redis-superset\"\nREDIS_PORT = \"6379\"\n\nclass CeleryConfig:\n BROKER_URL = 'redis://%s:%s/0' % (REDIS_HOST, REDIS_PORT)\n CELERY_IMPORTS = ('superset.sql_lab', \"superset.tasks\", \"superset.tasks.thumbnails\", )\n CELERY_RESULT_BACKEND = 'redis://%s:%s/0' % (REDIS_HOST, REDIS_PORT)\n CELERYD_PREFETCH_MULTIPLIER = 10\n CELERY_ACKS_LATE = True\n CELERY_ANNOTATIONS = {\n 'sql_lab.get_sql_results': {\n 'rate_limit': '100/s',\n },\n 'email_reports.send': {\n 'rate_limit': '1/s',\n 'time_limit': 600,\n 'soft_time_limit': 600,\n 'ignore_result': True,\n },\n }\n CELERYBEAT_SCHEDULE = {\n 'reports.scheduler': {\n 'task': 'reports.scheduler',\n 'schedule': crontab(minute='*', hour='*'),\n },\n 'reports.prune_log': {\n 'task': 'reports.prune_log',\n 'schedule': crontab(minute=0, hour=0),\n },\n }\nCELERY_CONFIG = CeleryConfig\n\nSCREENSHOT_LOCATE_WAIT = 100\nSCREENSHOT_LOAD_WAIT = 600\n\n# Slack configuration\nSLACK_API_TOKEN = \"xoxb-\"\n\n# Email configuration\nSMTP_HOST = \"smtp.sendgrid.net\" #change to your host\nSMTP_STARTTLS = True\nSMTP_SSL = False\nSMTP_USER = \"your_user\"\nSMTP_PORT = 2525 # your port eg. 587\nSMTP_PASSWORD = \"your_password\"\nSMTP_MAIL_FROM = \"noreply@youremail.com\"\n\n# WebDriver configuration\n# If you use Firefox, you can stick with default values\n# If you use Chrome, then add the following WEBDRIVER_TYPE and WEBDRIVER_OPTION_ARGS\nWEBDRIVER_TYPE = \"chrome\"\nWEBDRIVER_OPTION_ARGS = [\n \"--force-device-scale-factor=2.0\",\n \"--high-dpi-support=2.0\",\n \"--headless\",\n \"--disable-gpu\",\n \"--disable-dev-shm-usage\",\n \"--no-sandbox\",\n \"--disable-setuid-sandbox\",\n \"--disable-extensions\",\n]\n\n# This is for internal use, you can keep http\nWEBDRIVER_BASEURL=\"http://superset:8088\"\n# This is the link sent to the recipient, change to your domain eg. https://superset.mydomain.com\nWEBDRIVER_BASEURL_USER_FRIENDLY=\"http://localhost:8088\"\n")),Object(o.b)("h3",{id:"custom-dockerfile"},"Custom Dockerfile"),Object(o.b)("p",null,"A webdriver (and headless browser) is needed to capture screenshots of the charts and dashboards which are then sent to the recipient. As the base superset image does not have a webdriver installed, we need to extend it and install the webdriver."),Object(o.b)("h4",{id:"using-firefox"},"Using Firefox"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-docker"}),"FROM apache/superset:1.0.1\n\nUSER root\n\nRUN apt-get update && \\\n apt-get install --no-install-recommends -y firefox-esr\n\nENV GECKODRIVER_VERSION=0.29.0\nRUN wget -q https://github.com/mozilla/geckodriver/releases/download/v${GECKODRIVER_VERSION}/geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz && \\\n tar -x geckodriver -zf geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz -O > /usr/bin/geckodriver && \\\n chmod 755 /usr/bin/geckodriver && \\\n rm geckodriver-v${GECKODRIVER_VERSION}-linux64.tar.gz\n\nRUN pip install --no-cache gevent psycopg2 redis\n\nUSER superset\n")),Object(o.b)("h4",{id:"using-chrome"},"Using Chrome"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-docker"}),"FROM apache/superset:1.0.1\n\nUSER root\n\nRUN apt-get update && \\\n wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \\\n apt-get install -y --no-install-recommends ./google-chrome-stable_current_amd64.deb && \\\n rm -f google-chrome-stable_current_amd64.deb\n\nRUN export CHROMEDRIVER_VERSION=$(curl --silent https://chromedriver.storage.googleapis.com/LATEST_RELEASE_88) && \\\n wget -q https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip && \\\n unzip chromedriver_linux64.zip -d /usr/bin && \\\n chmod 755 /usr/bin/chromedriver && \\\n rm -f chromedriver_linux64.zip\n\nRUN pip install --no-cache gevent psycopg2 redis\n\nUSER superset\n")),Object(o.b)("blockquote",null,Object(o.b)("p",{parentName:"blockquote"},"Don't forget to set ",Object(o.b)("inlineCode",{parentName:"p"},"WEBDRIVER_TYPE")," and ",Object(o.b)("inlineCode",{parentName:"p"},"WEBDRIVER_OPTION_ARGS")," in your config if you use Chrome.")),Object(o.b)("h3",{id:"summary-of-steps-to-turn-on-alerts-and-reporting"},"Summary of steps to turn on alerts and reporting:"),Object(o.b)("p",null,"Using the templates below,"),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},"Create a new directory and create the Dockerfile"),Object(o.b)("li",{parentName:"ol"},"Build the extended image using the Dockerfile"),Object(o.b)("li",{parentName:"ol"},"Create the ",Object(o.b)("inlineCode",{parentName:"li"},"docker-compose.yaml")," file in the same directory"),Object(o.b)("li",{parentName:"ol"},"Create a new subdirectory called ",Object(o.b)("inlineCode",{parentName:"li"},"config")),Object(o.b)("li",{parentName:"ol"},"Create the ",Object(o.b)("inlineCode",{parentName:"li"},"superset_config.py")," file in the ",Object(o.b)("inlineCode",{parentName:"li"},"config")," subdirectory"),Object(o.b)("li",{parentName:"ol"},"Run the image using ",Object(o.b)("inlineCode",{parentName:"li"},"docker-compose up")," in the same directory as the ",Object(o.b)("inlineCode",{parentName:"li"},"docker-compose.py")," file"),Object(o.b)("li",{parentName:"ol"},"In a new terminal window, upgrade the DB by running ",Object(o.b)("inlineCode",{parentName:"li"},"docker exec -it superset-1.0.1-extended superset db upgrade")),Object(o.b)("li",{parentName:"ol"},"Then run ",Object(o.b)("inlineCode",{parentName:"li"},"docker exec -it superset-1.0.1-extended superset init")),Object(o.b)("li",{parentName:"ol"},"Then setup your admin user if need be, ",Object(o.b)("inlineCode",{parentName:"li"},"docker exec -it superset-1.0.1-extended superset fab create-admin")),Object(o.b)("li",{parentName:"ol"},"Finally, restart the running instance - ",Object(o.b)("inlineCode",{parentName:"li"},"CTRL-C"),", then ",Object(o.b)("inlineCode",{parentName:"li"},"docker-compose up"))),Object(o.b)("p",null,"(note: v 1.0.1 is current at time of writing, you can change the version number to the latest version if a newer version is available)"),Object(o.b)("h3",{id:"docker-compose"},"Docker compose"),Object(o.b)("p",null,"The docker compose file lists the services that will be used when running the image. The specific services needed for alerts and reporting are outlined below."),Object(o.b)("h4",{id:"redis-message-broker"},"Redis message broker"),Object(o.b)("p",null,"To ferry requests between the celery worker and the Superset instance, we use a message broker. This template uses Redis."),Object(o.b)("h4",{id:"replacing-sqlite-with-postgres"},"Replacing SQLite with Postgres"),Object(o.b)("p",null,"While it might be possible to use SQLite for alerts and reporting, it is highly recommended using a more production ready DB for Superset in general. Our template uses Postgres."),Object(o.b)("h4",{id:"celery-worker"},"Celery worker"),Object(o.b)("p",null,"The worker will process the tasks that need to be performed when an alert or report is fired."),Object(o.b)("h4",{id:"celery-beat"},"Celery beat"),Object(o.b)("p",null,"The beat is the scheduler that tells the worker when to perform its tasks. This schedule is defined when you create the alert or report."),Object(o.b)("h4",{id:"full-docker-composeyaml-configuration"},"Full ",Object(o.b)("inlineCode",{parentName:"h4"},"docker-compose.yaml")," configuration"),Object(o.b)("p",null,"The Redis, Postgres, Celery worker and Celery beat services are defined in the template:"),Object(o.b)("p",null,"Config for ",Object(o.b)("inlineCode",{parentName:"p"},"docker-compose.yaml"),":"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-docker"}),'version: \'3.6\'\nservices:\n redis:\n image: redis:6.0.9-buster\n restart: on-failure\n volumes:\n - redis:/data\n postgres:\n image: postgres\n restart: on-failure\n environment:\n POSTGRES_DB: superset\n POSTGRES_PASSWORD: superset\n POSTGRES_USER: superset\n volumes:\n - db:/var/lib/postgresql/data\n worker:\n image: superset-1.0.1-extended\n restart: on-failure\n healthcheck:\n disable: true\n depends_on:\n - superset\n - postgres\n - redis\n command: "celery --app=superset.tasks.celery_app:app worker --pool=gevent --concurrency=500"\n volumes:\n - ./config/:/app/pythonpath/\n beat:\n image: superset-1.0.1-extended\n restart: on-failure\n healthcheck:\n disable: true\n depends_on:\n - superset\n - postgres\n - redis\n command: "celery --app=superset.tasks.celery_app:app beat --pidfile /tmp/celerybeat.pid --schedule /tmp/celerybeat-schedule"\n volumes:\n - ./config/:/app/pythonpath/\n superset:\n image: superset-1.0.1-extended\n restart: on-failure\n environment:\n - SUPERSET_PORT=8088\n ports:\n - "8088:8088"\n depends_on:\n - postgres\n - redis\n command: gunicorn --bind 0.0.0.0:8088 --access-logfile - --error-logfile - --workers 5 --worker-class gthread --threads 4 --timeout 200 --limit-request-line 4094 --limit-request-field_size 8190 superset.app:create_app()\n volumes:\n - ./config/:/app/pythonpath/\nvolumes:\n db:\n external: true\n redis:\n external: false\n')),Object(o.b)("h3",{id:"summary"},"Summary"),Object(o.b)("p",null,"With the extended image created by using the ",Object(o.b)("inlineCode",{parentName:"p"},"Dockerfile"),", and then running that image using ",Object(o.b)("inlineCode",{parentName:"p"},"docker-compose.yaml"),", plus the required configurations in the ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," you should now have alerts and reporting working correctly."),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"The above templates also work in a Docker swarm environment, you would just need to add ",Object(o.b)("inlineCode",{parentName:"li"},"Deploy:")," to the Superset, Redis and Postgres services along with your specific configs for your swarm")),Object(o.b)("h1",{id:"old-reports-feature"},"Old Reports feature"),Object(o.b)("h2",{id:"scheduling-and-emailing-reports"},"Scheduling and Emailing Reports"),Object(o.b)("p",null,"(version 0.38 and below)"),Object(o.b)("h3",{id:"email-reports"},"Email Reports"),Object(o.b)("p",null,"Email reports allow users to schedule email reports for:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"chart and dashboard visualization (attachment or inline)"),Object(o.b)("li",{parentName:"ul"},"chart data (CSV attachment on inline table)")),Object(o.b)("p",null,"Enable email reports in your ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," file:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"ENABLE_SCHEDULED_EMAIL_REPORTS = True\n")),Object(o.b)("p",null,"This flag enables some permissions that are stored in your database, so you'll want to run ",Object(o.b)("inlineCode",{parentName:"p"},"superset init")," again if you are running this in a dev environment.\nNow you will find two new items in the navigation bar that allow you to schedule email reports:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"Manage > Dashboard Emails")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"Manage > Chart Email Schedules"))),Object(o.b)("p",null,"Schedules are defined in ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://crontab.guru/"}),"crontab format")," and each schedule can have a list\nof recipients (all of them can receive a single mail, or separate mails). For audit purposes, all\noutgoing mails can have a mandatory BCC."),Object(o.b)("p",null,"In order get picked up you need to configure a celery worker and a celery beat (see section above\n“Celery Tasks”). Your celery configuration also needs an entry ",Object(o.b)("inlineCode",{parentName:"p"},"email_reports.schedule_hourly")," for\n",Object(o.b)("inlineCode",{parentName:"p"},"CELERYBEAT_SCHEDULE"),"."),Object(o.b)("p",null,"To send emails you need to configure SMTP settings in your ",Object(o.b)("inlineCode",{parentName:"p"},"superset_config.py")," configuration file."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),'EMAIL_NOTIFICATIONS = True\n\nSMTP_HOST = "email-smtp.eu-west-1.amazonaws.com"\nSMTP_STARTTLS = True\nSMTP_SSL = False\nSMTP_USER = "smtp_username"\nSMTP_PORT = 25\nSMTP_PASSWORD = os.environ.get("SMTP_PASSWORD")\nSMTP_MAIL_FROM = "insights@komoot.com"\n')),Object(o.b)("p",null,"To render dashboards you need to install a local browser on your Superset instance:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://github.com/mozilla/geckodriver"}),"geckodriver")," for Firefox"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"http://chromedriver.chromium.org/"}),"chromedriver")," for Chrome")),Object(o.b)("p",null,"You'll need to adjust the ",Object(o.b)("inlineCode",{parentName:"p"},"WEBDRIVER_TYPE")," accordingly in your configuration. You also need\nto specify on behalf of which username to render the dashboards. In general dashboards and charts\nare not accessible to unauthorized requests, that is why the worker needs to take over credentials\nof an existing user to take a snapshot."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"THUMBNAIL_SELENIUM_USER = 'username_with_permission_to_access_dashboards'\n")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"Important notes")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"Be mindful of the concurrency setting for celery (using ",Object(o.b)("inlineCode",{parentName:"li"},"-c 4"),"). Selenium/webdriver instances can\nconsume a lot of CPU / memory on your servers."),Object(o.b)("li",{parentName:"ul"},"In some cases, if you notice a lot of leaked geckodriver processes, try running your celery\nprocesses with ",Object(o.b)("inlineCode",{parentName:"li"},"celery worker --pool=prefork --max-tasks-per-child=128 ...")),Object(o.b)("li",{parentName:"ul"},"It is recommended to run separate workers for the ",Object(o.b)("inlineCode",{parentName:"li"},"sql_lab")," and ",Object(o.b)("inlineCode",{parentName:"li"},"email_reports")," tasks. This can be\ndone using the ",Object(o.b)("inlineCode",{parentName:"li"},"queue")," field in ",Object(o.b)("inlineCode",{parentName:"li"},"CELERY_ANNOTATIONS"),"."),Object(o.b)("li",{parentName:"ul"},"Adjust ",Object(o.b)("inlineCode",{parentName:"li"},"WEBDRIVER_BASEURL")," in your configuration file if celery workers can’t access Superset via\nits default value of ",Object(o.b)("inlineCode",{parentName:"li"},"http://0.0.0.0:8080/"),".")),Object(o.b)("h3",{id:"schedule-reports"},"Schedule Reports"),Object(o.b)("p",null,"You can optionally allow your users to schedule queries directly in SQL Lab. This is done by addding\nextra metadata to saved queries, which are then picked up by an external scheduled (like\n",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://airflow.apache.org/"}),"Apache Airflow"),")."),Object(o.b)("p",null,"To allow scheduled queries, add the following to your configuration file:"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-python"}),"FEATURE_FLAGS = {\n # Configuration for scheduling queries from SQL Lab. This information is\n # collected when the user clicks \"Schedule query\", and saved into the `extra`\n # field of saved queries.\n # See: https://github.com/mozilla-services/react-jsonschema-form\n 'SCHEDULED_QUERIES': {\n 'JSONSCHEMA': {\n 'title': 'Schedule',\n 'description': (\n 'In order to schedule a query, you need to specify when it '\n 'should start running, when it should stop running, and how '\n 'often it should run. You can also optionally specify '\n 'dependencies that should be met before the query is '\n 'executed. Please read the documentation for best practices '\n 'and more information on how to specify dependencies.'\n ),\n 'type': 'object',\n 'properties': {\n 'output_table': {\n 'type': 'string',\n 'title': 'Output table name',\n },\n 'start_date': {\n 'type': 'string',\n 'title': 'Start date',\n # date-time is parsed using the chrono library, see\n # https://www.npmjs.com/package/chrono-node#usage\n 'format': 'date-time',\n 'default': 'tomorrow at 9am',\n },\n 'end_date': {\n 'type': 'string',\n 'title': 'End date',\n # date-time is parsed using the chrono library, see\n # https://www.npmjs.com/package/chrono-node#usage\n 'format': 'date-time',\n 'default': '9am in 30 days',\n },\n 'schedule_interval': {\n 'type': 'string',\n 'title': 'Schedule interval',\n },\n 'dependencies': {\n 'type': 'array',\n 'title': 'Dependencies',\n 'items': {\n 'type': 'string',\n },\n },\n },\n },\n 'UISCHEMA': {\n 'schedule_interval': {\n 'ui:placeholder': '@daily, @weekly, etc.',\n },\n 'dependencies': {\n 'ui:help': (\n 'Check the documentation for the correct format when '\n 'defining dependencies.'\n ),\n },\n },\n 'VALIDATION': [\n # ensure that start_date <= end_date\n {\n 'name': 'less_equal',\n 'arguments': ['start_date', 'end_date'],\n 'message': 'End date cannot be before start date',\n # this is where the error message is shown\n 'container': 'end_date',\n },\n ],\n # link to the scheduler; this example links to an Airflow pipeline\n # that uses the query id and the output table as its name\n 'linkback': (\n 'https://airflow.example.com/admin/airflow/tree?'\n 'dag_id=query_${id}_${extra_json.schedule_info.output_table}'\n ),\n },\n}\n")),Object(o.b)("p",null,"This feature flag is based on\n",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/mozilla-services/react-jsonschema-form"}),"react-jsonschema-form")," and will add a\nbutton called “Schedule Query” to SQL Lab. When the button is clicked, a modal will show up where\nthe user can add the metadata required for scheduling the query."),Object(o.b)("p",null,"This information can then be retrieved from the endpoint ",Object(o.b)("inlineCode",{parentName:"p"},"/savedqueryviewapi/api/read")," and used to\nschedule the queries that have ",Object(o.b)("inlineCode",{parentName:"p"},"scheduled_queries")," in their JSON metadata. For schedulers other than\nAirflow, additional fields can be easily added to the configuration file above."))}void 0!==b&&b&&b===Object(b)&&Object.isExtensible(b)&&!b.hasOwnProperty("__filemeta")&&Object.defineProperty(b,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/pages/docs/installation/alerts_reports.mdx"}}),b.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-pages-docs-installation-alerts-reports-mdx-1b84aca3470a37db6ee0.js.map