blob: 7f8f42a40c95ca12a1e953046c2cdccc1a2abdfd [file] [log] [blame]
{"version":3,"sources":["webpack:///./src/pages/docs/installation/email_reports.mdx"],"names":["_frontmatter","layoutProps","MDXLayout","DefaultLayout","MDXContent","components","props","mdxType","parentName","isMDXComponent"],"mappings":"wPAQaA,G,UAAe,S,+NAC5B,IAAMC,EAAc,CAClBD,gBAEIE,EAAYC,IACH,SAASC,EAAT,GAGZ,IAFDC,EAEC,EAFDA,WACGC,EACF,8BACD,OAAO,YAACJ,EAAD,eAAeD,EAAiBK,EAAhC,CAAuCD,WAAYA,EAAYE,QAAQ,cAG5E,iBAAQ,CACN,GAAM,mCADR,mCAGA,iBAAQ,CACN,GAAM,iBADR,iBAGA,iFACA,sBACE,kBAAIC,WAAW,MAAf,4DACA,kBAAIA,WAAW,MAAf,gDAEF,qDAAoC,0BAAYA,WAAW,KAAvB,sBAApC,UACA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,oBADZ,4CAIL,mHAAkG,0BAAYA,WAAW,KAAvB,iBAAlG,yJAEA,sBACE,kBAAIA,WAAW,MAAK,sBAAQA,WAAW,MAAnB,8BACpB,kBAAIA,WAAW,MAAK,sBAAQA,WAAW,MAAnB,oCAEtB,iDAAgC,6BAAGA,WAAW,KAAQ,CAClD,KAAQ,0BADoB,kBAAhC,mLAKA,0LAC6D,0BAAYA,WAAW,KAAvB,iCAD7D,SAEF,0BAAYA,WAAW,KAAvB,uBAFE,KAGA,mFAAkE,0BAAYA,WAAW,KAAvB,sBAAlE,wBACA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,oBADZ,mQAYL,4GACA,sBACE,kBAAIA,WAAW,MAAK,6BAAGA,WAAW,MAAS,CACvC,KAAQ,2CADQ,eAApB,gBAGA,kBAAIA,WAAW,MAAK,6BAAGA,WAAW,MAAS,CACvC,KAAQ,sCADQ,gBAApB,gBAIF,kDAAiC,0BAAYA,WAAW,KAAvB,2BAAjC,qSAIA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,oBADZ,2EAIL,qBAAG,sBAAQA,WAAW,KAAnB,oBACH,sBACE,kBAAIA,WAAW,MAAf,2DAAgF,0BAAYA,WAAW,MAAvB,QAAhF,uFAEA,kBAAIA,WAAW,MAAf,+GACW,0BAAYA,WAAW,MAAvB,+DACX,kBAAIA,WAAW,MAAf,qDAA0E,0BAAYA,WAAW,MAAvB,WAA1E,QAAuI,0BAAYA,WAAW,MAAvB,iBAAvI,uCACW,0BAAYA,WAAW,MAAvB,SADX,aAC2E,0BAAYA,WAAW,MAAvB,sBAD3E,KAEA,kBAAIA,WAAW,MAAf,UAA+B,0BAAYA,WAAW,MAAvB,qBAA/B,iGACiB,0BAAYA,WAAW,MAAvB,wBADjB,MAGF,iBAAQ,CACN,GAAM,oBADR,oBAGA,wNAEF,6BAAGA,WAAW,KAAQ,CAChB,KAAQ,gCADd,kBAFE,MAKA,kGACA,uBAAK,gCAAMA,WAAW,OAAU,CAC5B,UAAa,oBADZ,svGAmFL,uDACF,6BAAGA,WAAW,KAAQ,CAChB,KAAQ,8DADd,yBADE,wLAMA,iFAAgE,0BAAYA,WAAW,KAAvB,+BAAhE,gDAC6B,0BAAYA,WAAW,KAAvB,qBAD7B,6I,6NAOJJ,EAAWK,gBAAiB","file":"component---src-pages-docs-installation-email-reports-mdx-dba351d113a33c78cb7b.js","sourcesContent":["import * as React from 'react'\n /* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\n\nimport DefaultLayout from \"/Users/srinify/Documents/superset/docs/node_modules/gatsby-theme-docz/src/base/Layout.js\";\nexport const _frontmatter = {};\nconst layoutProps = {\n _frontmatter\n};\nconst MDXLayout = DefaultLayout;\nexport default function MDXContent({\n components,\n ...props\n}) {\n return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\"MDXLayout\">\n\n\n <h2 {...{\n \"id\": \"scheduling-and-emailing-reports\"\n }}>{`Scheduling and Emailing Reports`}</h2>\n <h3 {...{\n \"id\": \"email-reports\"\n }}>{`Email Reports`}</h3>\n <p>{`Email reports allow users to schedule email reports for:`}</p>\n <ul>\n <li parentName=\"ul\">{`chart and dashboard visualization (attachment or inline)`}</li>\n <li parentName=\"ul\">{`chart data (CSV attachment on inline table)`}</li>\n </ul>\n <p>{`Enable email reports in your `}<inlineCode parentName=\"p\">{`superset_config.py`}</inlineCode>{` file:`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-python\"\n }}>{`ENABLE_SCHEDULED_EMAIL_REPORTS = True\n`}</code></pre>\n <p>{`This flag enables some permissions that are stored in your database, so you'll want to run `}<inlineCode parentName=\"p\">{`superset init`}</inlineCode>{` 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:`}</p>\n <ul>\n <li parentName=\"ul\"><strong parentName=\"li\">{`Manage > Dashboard Emails`}</strong></li>\n <li parentName=\"ul\"><strong parentName=\"li\">{`Manage > Chart Email Schedules`}</strong></li>\n </ul>\n <p>{`Schedules are defined in `}<a parentName=\"p\" {...{\n \"href\": \"https://crontab.guru/\"\n }}>{`crontab format`}</a>{` 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.`}</p>\n <p>{`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 `}<inlineCode parentName=\"p\">{`email_reports.schedule_hourly`}</inlineCode>{` for\n`}<inlineCode parentName=\"p\">{`CELERYBEAT_SCHEDULE`}</inlineCode>{`.`}</p>\n <p>{`To send emails you need to configure SMTP settings in your `}<inlineCode parentName=\"p\">{`superset_config.py`}</inlineCode>{` configuration file.`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-python\"\n }}>{`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`}</code></pre>\n <p>{`To render dashboards you need to install a local browser on your Superset instance:`}</p>\n <ul>\n <li parentName=\"ul\"><a parentName=\"li\" {...{\n \"href\": \"https://github.com/mozilla/geckodriver\"\n }}>{`geckodriver`}</a>{` for Firefox`}</li>\n <li parentName=\"ul\"><a parentName=\"li\" {...{\n \"href\": \"http://chromedriver.chromium.org/\"\n }}>{`chromedriver`}</a>{` for Chrome`}</li>\n </ul>\n <p>{`You'll need to adjust the `}<inlineCode parentName=\"p\">{`EMAIL_REPORTS_WEBDRIVER`}</inlineCode>{` 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.`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-python\"\n }}>{`EMAIL_REPORTS_USER = 'username_with_permission_to_access_dashboards'\n`}</code></pre>\n <p><strong parentName=\"p\">{`Important notes`}</strong></p>\n <ul>\n <li parentName=\"ul\">{`Be mindful of the concurrency setting for celery (using `}<inlineCode parentName=\"li\">{`-c 4`}</inlineCode>{`). Selenium/webdriver instances can\nconsume a lot of CPU / memory on your servers.`}</li>\n <li parentName=\"ul\">{`In some cases, if you notice a lot of leaked geckodriver processes, try running your celery\nprocesses with `}<inlineCode parentName=\"li\">{`celery worker --pool=prefork --max-tasks-per-child=128 ...`}</inlineCode></li>\n <li parentName=\"ul\">{`It is recommended to run separate workers for the `}<inlineCode parentName=\"li\">{`sql_lab`}</inlineCode>{` and `}<inlineCode parentName=\"li\">{`email_reports`}</inlineCode>{` tasks. This can be\ndone using the `}<inlineCode parentName=\"li\">{`queue`}</inlineCode>{` field in `}<inlineCode parentName=\"li\">{`CELERY_ANNOTATIONS`}</inlineCode>{`.`}</li>\n <li parentName=\"ul\">{`Adjust `}<inlineCode parentName=\"li\">{`WEBDRIVER_BASEURL`}</inlineCode>{` in your configuration file if celery workers can’t access Superset via\nits default value of `}<inlineCode parentName=\"li\">{`http://0.0.0.0:8080/`}</inlineCode>{`.`}</li>\n </ul>\n <h3 {...{\n \"id\": \"schedule-reports\"\n }}>{`Schedule Reports`}</h3>\n <p>{`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`}<a parentName=\"p\" {...{\n \"href\": \"https://airflow.apache.org/\"\n }}>{`Apache Airflow`}</a>{`).`}</p>\n <p>{`To allow scheduled queries, add the following to your configuration file:`}</p>\n <pre><code parentName=\"pre\" {...{\n \"className\": \"language-python\"\n }}>{`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`}</code></pre>\n <p>{`This feature flag is based on\n`}<a parentName=\"p\" {...{\n \"href\": \"https://github.com/mozilla-services/react-jsonschema-form\"\n }}>{`react-jsonschema-form`}</a>{` 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.`}</p>\n <p>{`This information can then be retrieved from the endpoint `}<inlineCode parentName=\"p\">{`/savedqueryviewapi/api/read`}</inlineCode>{` and used to\nschedule the queries that have `}<inlineCode parentName=\"p\">{`scheduled_queries`}</inlineCode>{` in their JSON metadata. For schedulers other than\nAirflow, additional fields can be easily added to the configuration file above.`}</p>\n\n </MDXLayout>;\n}\n;\nMDXContent.isMDXComponent = true;\n "],"sourceRoot":""}